maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Clean way to add/remove LED patterns to mce.ini (https://talk.maemo.org/showthread.php?t=45614)

rambo 2010-02-23 21:08

Clean way to add/remove LED patterns to mce.ini
 
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)

rambo 2010-02-23 21:12

Re: Clean way to add/remove LED patterns to mce.ini
 
Quote:

Originally Posted by rambo (Post 543289)
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.

rambo 2010-02-28 11:19

Re: Clean way to add/remove LED patterns to mce.ini
 
Quote:

Originally Posted by rambo (Post 543298)
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).

tmsha 2010-02-28 12:59

Re: Clean way to add/remove LED patterns to mce.ini
 
Is this what you need ?

http://my-maemo.com/software/applica...to=1275&faq=42

pH5 2010-02-28 16:18

Re: Clean way to add/remove LED patterns to mce.ini
 
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.

raverpol 2010-02-28 16:22

Re: Clean way to add/remove LED patterns to mce.ini
 
u have to search forum better hehe
http://talk.maemo.org/showthread.php?t=46054

rambo 2010-02-28 20:23

Re: Clean way to add/remove LED patterns to mce.ini
 
Quote:

Originally Posted by pH5 (Post 549967)
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.

rambo 2010-02-28 21:43

Re: Clean way to add/remove LED patterns to mce.ini
 
Removal seems to work cleanly now too, basically only pattern sanity-checking remains and then this tool is ready.

rambo 2010-03-01 09:42

Re: Clean way to add/remove LED patterns to mce.ini
 
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.

pH5 2010-03-01 10:01

Re: Clean way to add/remove LED patterns to mce.ini
 
Quote:

Originally Posted by rambo (Post 550780)
[...] 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 ...


All times are GMT. The time now is 20:41.

vBulletin® Version 3.8.8