Active Topics

 


Reply
Thread Tools
Posts: 540 | Thanked: 288 times | Joined on Sep 2009
#1
The idea is that I have an application and I would like to add a custom LED pattern, this means manipulating the mce.ini, adding first the pattern definition to correct section and then the pattern to the patterns to be loaded list.

I can do this in python via the ConfigParser module, but it will strip all comments when writing the modified file (which is kind of obvious and I was expecting it to happen), this is undesirable. There have been suggested patches to ConfigParser for "surgical" editing but nothing has come of them.

Basically idea is to add a new mySuperCoolLedPattern at postinstall and remove it at postrm without messing up rest of the mce.ini.

So I wonder what would be the cleanest way to do this (writing my own config file parser that supports only the very small subset of features required to do this? anyway there needs to be some extra logic since the LEDPatterns variable is not a proper dictionary but just semicolon separate values)
__________________
  • Live near Helsinki, Finland & interested in electronics ? Check this out.
  • Want anti-virus/firewall ? Read this (and follow the links, also: use the search, there are way too many threads asking the same questions over and over and over again).
  • I'm experimenting with BitCoins, if you want to tip me send some to: 1CAEy7PYptSasN67TiMYM74ELDVGZS6cCB
 

The Following User Says Thank You to rambo For This Useful Post:
Posts: 540 | Thanked: 288 times | Joined on Sep 2009
#2
Originally Posted by rambo View Post
I can do this in python via the ConfigParser module, but it will strip all comments when writing the modified file (which is kind of obvious and I was expecting it to happen), this is undesirable
Also it seems ConfigParser rewrites the variable (not section) names to lowercase, this is potentially fatal...

So unless someone has made such a tool already it seems I will have to write one.
__________________
  • Live near Helsinki, Finland & interested in electronics ? Check this out.
  • Want anti-virus/firewall ? Read this (and follow the links, also: use the search, there are way too many threads asking the same questions over and over and over again).
  • I'm experimenting with BitCoins, if you want to tip me send some to: 1CAEy7PYptSasN67TiMYM74ELDVGZS6cCB
 
Posts: 540 | Thanked: 288 times | Joined on Sep 2009
#3
Originally Posted by rambo View Post
So unless someone has made such a tool already it seems I will have to write one.
First version of mce_ledpattern.py, adding patterns seems to work (did not test on device yet).

I'll look at removing later (it requires a bit more sophistication to do it the way I would like to).
__________________
  • Live near Helsinki, Finland & interested in electronics ? Check this out.
  • Want anti-virus/firewall ? Read this (and follow the links, also: use the search, there are way too many threads asking the same questions over and over and over again).
  • I'm experimenting with BitCoins, if you want to tip me send some to: 1CAEy7PYptSasN67TiMYM74ELDVGZS6cCB
 

The Following User Says Thank You to rambo For This Useful Post:
Posts: 60 | Thanked: 23 times | Joined on Jan 2010
#4
 
pH5's Avatar
Posts: 138 | Thanked: 375 times | Joined on Aug 2009 @ Berlin
#5
There is a helper binary shipped with the LED pattern editor that can check patterns for correctness, overwrite mce.ini and restart mce. But it only supports changing existing patterns, not adding new ones (because the pattern editor doesn't need that). So the two tools have kind of orthogonal functionality.
 
Posts: 356 | Thanked: 69 times | Joined on Jan 2010 @ Poland
#6
u have to search forum better hehe
http://talk.maemo.org/showthread.php?t=46054
 
Posts: 540 | Thanked: 288 times | Joined on Sep 2009
#7
Originally Posted by pH5 View Post
There is a helper binary shipped with the LED pattern editor that can check patterns for correctness, overwrite mce.ini and restart mce. But it only supports changing existing patterns, not adding new ones (because the pattern editor doesn't need that). So the two tools have kind of orthogonal functionality.
Yep, adding and removing patterns from cli is vital so that it programs can install new patterns (or overwrite old ones and then restore previous version on uninstall).

The editor is a nice idea and I was thinking of something simple along the lines as well, need to check it out at some point (for example if it would allow copying the pattern to clipboard instead of overwriting mce.ini it would be a handy tool for generating patterns to be used with my tool later).

edit: pattern format correctness check I was planning on adding as well.
__________________
  • Live near Helsinki, Finland & interested in electronics ? Check this out.
  • Want anti-virus/firewall ? Read this (and follow the links, also: use the search, there are way too many threads asking the same questions over and over and over again).
  • I'm experimenting with BitCoins, if you want to tip me send some to: 1CAEy7PYptSasN67TiMYM74ELDVGZS6cCB

Last edited by rambo; 2010-02-28 at 20:30.
 
Posts: 540 | Thanked: 288 times | Joined on Sep 2009
#8
Removal seems to work cleanly now too, basically only pattern sanity-checking remains and then this tool is ready.
__________________
  • Live near Helsinki, Finland & interested in electronics ? Check this out.
  • Want anti-virus/firewall ? Read this (and follow the links, also: use the search, there are way too many threads asking the same questions over and over and over again).
  • I'm experimenting with BitCoins, if you want to tip me send some to: 1CAEy7PYptSasN67TiMYM74ELDVGZS6cCB
 
Posts: 540 | Thanked: 288 times | Joined on Sep 2009
#9
Ok, the package is in extras-devel, since it's meant mainly to be used by other programs it's in system not user/system section.
__________________
  • Live near Helsinki, Finland & interested in electronics ? Check this out.
  • Want anti-virus/firewall ? Read this (and follow the links, also: use the search, there are way too many threads asking the same questions over and over and over again).
  • I'm experimenting with BitCoins, if you want to tip me send some to: 1CAEy7PYptSasN67TiMYM74ELDVGZS6cCB
 

The Following 2 Users Say Thank You to rambo For This Useful Post:
pH5's Avatar
Posts: 138 | Thanked: 375 times | Joined on Aug 2009 @ Berlin
#10
Originally Posted by rambo View Post
[...] since it's meant mainly to be used by other programs it's in system not user/system section.
Great work. To maximize acceptance, it would be a good idea to remove the python dependency, though. Imagine a user without python installed downloading a small C program that wants to register its own LED pattern ...
 

The Following User Says Thank You to pH5 For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 11:19.