[sugar] [PATCH] Trac #7480: Need to 'reset' the network configurations - short term fix

Erik Garrison erik
Thu Aug 14 11:12:09 EDT 2008


On Tue, Aug 12, 2008 at 12:02:41AM -0400, Michael Stone wrote:
> On Mon, Aug 11, 2008 at 09:31:26PM -0400, Erik Garrison wrote:
>> Attached is a patch which adds a 'reset network configuration' button to
>> the network tab of the sugar control panel.
>
> Thanks very much for the patch, and for the thoughtful design.
>
>> +        n = 1 + max(map(lambda x: int(x.replace('networks.cfg.bak.', '')),
>> +                        network_cfgs))
>
> This expression, while cute, is unsafe and will result in failure if you
> ever encounter a file with a name like 'networks.cfg.bak.hi'. 

The solution is to guarantee that inputs are of the correct form
(networks.cfg.bak.\d+$).  As follows, two lines previously should be:

    network_cfgs = [file
                    for file in os.listdir('/home/olpc/.sugar/default/nm')
                    if re.match('networks.cfg.bak.\d+$', file)]

> Please write total code or handle exceptions appropriately.

I don't understand what you mean by 'total' code.  You do not need to
ask me to write bug-free code.  That is what I'm trying to do.  Pleaese
just say 'I found a problem' and update the patch.

> (Incidentally, does anything bad happen if your code does happen to
> generate exceptions?)

I have no idea and I don't expect I will have time to test it prior to
my departure.

Sorry.

Erik



More information about the Sugar-devel mailing list