Re: [Sugar-devel] [PATCH v2 Browse] Remove temporary downloaded (cancelled) files SL #3973

2012-10-03 Thread Manuel Kaufmann
On Wed, Oct 3, 2012 at 12:08 PM, Martin Langhoff wrote: > Not at all. Ignoring the computer is not elegance. OK. I will send a new version of this patch with all the things that we were discussing. -- Kaufmann Manuel Blog: http://humitos.wordpress.com/ Porfolio: http://fotos.mkaufmann.com.ar/ P

Re: [Sugar-devel] [PATCH v2 Browse] Remove temporary downloaded (cancelled) files SL #3973

2012-10-03 Thread Martin Langhoff
On Wed, Oct 3, 2012 at 6:52 AM, Manuel Kaufmann wrote: > On Tue, Oct 2, 2012 at 5:35 PM, Martin Langhoff > wrote: >> Actually, the answer is to avoid datetime. It's fine for high level >> work; when you care about times defined as epoch values, you > > Yes, you are right. But datetime is much mor

Re: [Sugar-devel] [PATCH v2 Browse] Remove temporary downloaded (cancelled) files SL #3973

2012-10-03 Thread Manuel Kaufmann
On Tue, Oct 2, 2012 at 5:35 PM, Martin Langhoff wrote: > Actually, the answer is to avoid datetime. It's fine for high level > work; when you care about times defined as epoch values, you Yes, you are right. But datetime is much more elegant and makes the code much more easy to read and follow. P

Re: [Sugar-devel] [PATCH v2 Browse] Remove temporary downloaded (cancelled) files SL #3973

2012-10-02 Thread Martin Langhoff
On Tue, Oct 2, 2012 at 3:51 PM, Martin Langhoff wrote: > Works as pseudocode. But I took a quick look at the datetime docs and > it is... horrible. We want to be doing math on the epoch (seconds > since 1970). > > They refuse to document it properly, but the answer to the riddle is > >datetime

Re: [Sugar-devel] [PATCH v2 Browse] Remove temporary downloaded (cancelled) files SL #3973

2012-10-02 Thread Martin Langhoff
On Tue, Oct 2, 2012 at 2:52 PM, Manuel Kaufmann wrote: > On Tue, Oct 2, 2012 at 1:43 PM, Martin Langhoff > wrote: >>> +except: >>> +logging.warning('/proc/uptime could not be read') >>> +uptime = None > > Should I use EnvironmentError[1] here too? Yep. A bare 'exc

Re: [Sugar-devel] [PATCH v2 Browse] Remove temporary downloaded (cancelled) files SL #3973

2012-10-02 Thread Manuel Kaufmann
On Tue, Oct 2, 2012 at 1:43 PM, Martin Langhoff wrote: >> +except: >> +logging.warning('/proc/uptime could not be read') >> +uptime = None Should I use EnvironmentError[1] here too? > Tiny optimization and elegance improvement: just calculate your cutoff > here. T

Re: [Sugar-devel] [PATCH v2 Browse] Remove temporary downloaded (cancelled) files SL #3973

2012-10-02 Thread Martin Langhoff
On Tue, Oct 2, 2012 at 9:59 AM, Manuel Kaufmann wrote: > +try: > +uptime_proc = open('/proc/uptime', 'r').read() > +uptime_seconds = float(uptime_proc.split()[0]) > +uptime = datetime.timedelta(seconds=uptime_seconds) > +except: > +lo

[Sugar-devel] [PATCH v2 Browse] Remove temporary downloaded (cancelled) files SL #3973

2012-10-02 Thread Manuel Kaufmann
When a download is cancelled for any reason WebKit leaves a temporary file called ".goutputstream-*" in the "instance" directory. This is because of a bug in GLib: * https://bugzilla.gnome.org/show_bug.cgi?id=629301 This patch is a workaround to that behaviour. Every time that Browse is started