[Sugar-devel] [PATCH v2 Browse] Remove temporary downloaded (cancelled) files SL #3973
Martin Langhoff
martin.langhoff at gmail.com
Tue Oct 2 15:51:20 EDT 2012
On Tue, Oct 2, 2012 at 2:52 PM, Manuel Kaufmann <humitos at gmail.com> wrote:
> On Tue, Oct 2, 2012 at 1:43 PM, Martin Langhoff
> <martin.langhoff at gmail.com> wrote:
>>> + except:
>>> + logging.warning('/proc/uptime could not be read')
>>> + uptime = None
>
> Should I use EnvironmentError[1] here too?
Yep. A bare 'except:' hides other things like syntax errors.
> What do you think about this?
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.datetime.now().strftime('%s.%f')
So this is probably closer, using only ints:
boot_time = int(boot_time) # discard the float part
now = datetime.datetime.now().strftime('%s')
cutoff = now - 24 * 60 * 60
if uptime is not None:
boot_time = now - uptime
cutoff = max(cutoff, boot_time)
enjoy,
m
--
martin.langhoff at gmail.com
martin at laptop.org -- Software Architect - OLPC
- ask interesting questions
- don't get distracted with shiny stuff - working code first
- http://wiki.laptop.org/go/User:Martinlanghoff
More information about the Sugar-devel
mailing list