how to save HOURS of time with python...

Michal Wallace sabren at manifestation.com
Sun Oct 8 00:19:51 EDT 2000


#!/usr/home/sabren/bin/python
"""
I waste way too much time checking email.
This is a little script to prevent me
from checking email too often.
"""
import os, stat, time

## how long to wait between allowing email checks?
DELAY = 120


## calculate the time in seconds since I last checked
## mail (which is the last time this program ran, and
## also the last time this file was modified, because
## I call touch, below..)
modtime = os.stat('/usr/home/sabren/bin/pine')[stat.ST_MTIME]
elapsed = time.time()-modtime 


## now, see if it was less than DELAY mins ago:
if elapsed < DELAY * 60:
    print "not for another %i minutes..." \
          % (DELAY - int(elapsed/60))

else:
    ## i can check mail! :)
    os.system('/usr/local/bin/pine')
    ## all done. no more mail for a while:
    os.system('touch /usr/home/sabren/bin/pine')


"""
'Nuff said. :)

Cheers,

- Michal
------------------------------------------------------------------------
www.manifestation.com  www.sabren.com  www.linkwatcher.com  www.zike.net
------------------------------------------------------------------------
"""





More information about the Python-list mailing list