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

Erik Garrison erik
Thu Aug 14 11:52:46 EDT 2008


On Thu, Aug 14, 2008 at 11:44:12AM -0400, Erik Garrison wrote:
> On Thu, Aug 14, 2008 at 11:34:58AM -0400, Michael Stone wrote:
> > On Thu, Aug 14, 2008 at 11:12:09AM -0400, Erik Garrison wrote:
> >> 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.  
> >
> > Total (as opposed to partial) functions, programs, expressions, etc. are
> > defined for every possible input rather than for only some of their
> > inputs. The way you defined network_cfgs was partial in that, in
> > addition to generating an exception, it also left "n" undefined (not
> > even set to None) for some inputs (such as those I described).
> >
> >> You do not need to ask me to write bug-free code. 
> >
> > There are actually lots of people (including myself) who I find I have
> > to ask to write bug-free code (often concerning race conditions).
> > However, I'm glad to hear that you care deeply about it as well.
> >
> >> Please just say 'I found a problem' and update the patch.
> >
> > As you prefer.
> 
> Michael,
> 
> Sorry to be so testy, it was completely unecessary to nitpick your
> comments!  I obviously am rushing to get this done and perhaps it is
> better to ask me to be careful as I do so than not.
 
By which I meant "I obviously am rushing to get this done and perhaps it
is better to ask me to be careful than not."



More information about the Sugar-devel mailing list