[Tutor] Dial-up time logger

André Dahlqvist andre@beta.telenordia.se
Sat, 10 Jun 2000 16:32:12 +0200


Hi

I'm going to write a program that records the time I spend online. I
know such programs already exist, but I'd like to write one myself in
python.

I have planned to simply do a start = time.time() when the connection
starts and end = time.time() when it ends, and then compare those two
values, perhaps dividing them with 60 to get time in minutes. Then I
would like to store the value in a dictionary, with the current date as
a key in this format:

time.strf("%Y-%m-%d", time.localtime(time.time())

Then I could use cPickle to store this dictionary in a file. I know how
to have a program or command run when I go online, and a program run
when I go offline, but how to I tie them together? I could write a
program that would start when I get connected, and store the time when
then happened. And then have another program kill the first program
when I go offline. But how would I then store the time I went offline?
-- 

// André