Archive for December, 2007

-controls update

Well, seeing as I posted about this earlier, I might as well give it an update.

Thanks to my own testing (I wish I had a userbase, but that would have meant some very angry people due to data loss bugs), I have fixed several bugs in changesettings.py in regards to reading the file and changing the line replacement while the class is instanced. (As I write this right now, I am realizing I need to make a similar change to the set up of the regular expression…. just to make the whole thing nice and manageable)

The previous revisions could eat your data because: 1) when you read a buffer in python, it is emptied (very c like if you ask me) and 2) the class was not re-searching the file after the inital change. The end result of both of those two things were that if you changed the setting twice, it would overwrite the file with the empty buffer and all that would be left would be the replacement string. The other issue resulted in the append/update logic being static.

Both of theseĀ  issues have been fixed as of rev 35 iirc in the mainline ubuntustudio-controls branch.

Home for the Holidays

Well after two days MIA, I have made it back to Toronto from Newcastle. Its great to spend time with one’s family and even better not to have to think about what you are going to have for dinner. :p

ubuntustudio-controls

I felt the need to blog about this small settings app that is being developed by Luis and myself called ubuntustudio-controls. The aim of this app is create an easier way for users to modify several settings that are currently modified by hand.

The design of -controls is such that it is DE agnostic. Currently we are only developing a front-end for Gnome, but the backend class that I wrote can be used in any python code.

A quick explanation on how it works

When the changesettings class is initialized it needs to be given three pieces of information :

1) The file to operate on

2) A python regular expression

3) The string you want to replace or add.


import changesettings
inst = changesettings('file', '\d', '1')
inst.ch_setting()
inst.rm_setting()

changesettings defines two methods, ch_setting and rm_setting. ch_setting will search the file for a string matching the python regular expression and if it exists, change it. Otherwise, it will append it to the second last line. (This may change in the future to allow the class to append it anywhere in the file.)

The second method defined does the same as the first, except it will remove the string.

The code is available from the ubuntustudio-controls project page on launchpad, but here is a link for all you lazy people.