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 ...

rambo 2010-03-01 11:11

Re: Clean way to add/remove LED patterns to mce.ini
 
Promoted mceledpattern to extras-testing (again; it's not in user sections so to test you need to "apt-get install mceledpattern" instead of using HAM)

As for changing from python to a compiled language, we have had some PM discussions about this with ph5 and I agree it's a good idea but right now I don't have resources.

rambo 2010-03-02 21:26

Re: Clean way to add/remove LED patterns to mce.ini
 
Sleep be damned, been reading some Vala tutorials and though my weekend is fully booked already (budo seminar) it is possible that a Vala rewrite of my tool is coming at the end of the week anyway (especially if ph5 has time to help as he suggested he might)

rambo 2010-03-03 21:46

Re: Clean way to add/remove LED patterns to mce.ini
 
Vala rewrite WIP, I'm learning Vala as I go so this is a bit of a stub still...

rambo 2010-03-04 18:46

Re: Clean way to add/remove LED patterns to mce.ini
 
Thanks to a little help from ph5 I managed to finish the rewrite, new version should be landing to extras testing soon.

qole 2010-03-04 21:25

Re: Clean way to add/remove LED patterns to mce.ini
 
So now can you expand your tool to be a more generic mce editor? I would like to do the same thing, except I'd like to add vibrator patterns.

rambo 2010-03-05 06:10

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

Originally Posted by qole (Post 556111)
So now can you expand your tool to be a more generic mce editor? I would like to do the same thing, except I'd like to add vibrator patterns.

I wasn't planning on making it *actually* generic (it would make the command-line options jungle so complicated that one would be better of using just sed), but adding handling for vibrator patterns as well should not be hard.

rambo 2010-03-05 21:16

Re: Clean way to add/remove LED patterns to mce.ini
 
Added a very ugly copy-paste solution for vibra patterns (not even tested yet), this raises the code smellines factor so high that refactoring needs to be done Real Soon Now.

raghavmurali 2010-03-05 21:37

Re: Clean way to add/remove LED patterns to mce.ini
 
not able to install from the site

rambo 2010-03-06 06:52

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

Originally Posted by raghavmurali (Post 557323)
not able to install from the site

"from the site" ? As in which site etc ? This program is not in user/xx -category (since it's cli helper aimed mostly for developers of programs like the led pattern editor)

You need to install it via dpkg (first download the deb) or via apt-get (extras-testing repo), if you don't know how to do these things then this tool is not for you.

rambo 2010-03-06 07:26

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

Originally Posted by rambo (Post 557304)
Added a very ugly copy-paste solution for vibra patterns (not even tested yet), this raises the code smellines factor so high that refactoring needs to be done Real Soon Now.

Of course the copy-paste version was buggy, but I fixed the bugs (not yet refactoring the code, that will take more than 30min...) and uploaded a new package version to autobuilder.

Don't have time to wait for it to land in devel repo so I could promote it, so if you want to test the latest version check the -devel repo.

rambo 2010-03-06 19:54

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

Originally Posted by rambo (Post 557304)
Added a very ugly copy-paste solution for vibra patterns (not even tested yet), this raises the code smellines factor so high that refactoring needs to be done Real Soon Now.

And it's done. Now adding support for anything that follows the same logic (one section [and config key] for enabling, another for the patterns themselves) as vibra/led patterns is going to be easy.

I'll promote the 0.4.0 version to extras testing when I get back from sauna.

ph5: we could probably add use of your more sophisticated pattern sanity checks but the live-test code should be a separate tool (and doing mce.ini update+mce daemon restart should probably be a small shell script first calling my tool and then if exit code is ok restart mce [this is what I intent to do on postinstall of the prog I needed this tool for...])

rambo 2010-03-12 20:37

Re: Clean way to add/remove LED patterns to mce.ini
 
Made some packaging adjustments and promoted as 1.0.0 to extras-testing.

Edit: Made announcement thread.


All times are GMT. The time now is 01:29.

vBulletin® Version 3.8.8