[Tutor] TimeTracker

Kyle Babich kb@mm.st
Tue, 6 Aug 2002 20:07:48 UT


For those of you who remember TimeTracker, I've begun rewriting my
first and only program for v0.1.0.

I'm getting this error:
Traceback (most recent call last):
  File "C:\WINDOWS\Desktop\TimeTracker\TimeTracker_0_1_0.py", line 65,
  in ?
    sleep( tosleep )
  File "C:\WINDOWS\Desktop\TimeTracker\TimeTracker_0_1_0.py", line 22,
  in sleep
    int (sleeptime)
ValueError: int() literal too large:
111111111111111111111111111111111111111111111111111111111111

The problem seems to be where I am declaring the input an integer and
then putting the integer into the function, but once again I'm not sure
how to change this and make it work.

Here is the complete program:

#####################################################

#! C:\Python22\python

import time, sys

def sleep(a):
    currtime =3D time.strftime( "%I:%M:%S%p %Z" )
    print "Current time:  %(currtime)s" % vars()

    begin =3D raw_input( "Begin tracking?  [Y/N]:  " )

    if begin.lower() in "y yes".split():
        logcurrtime =3D open( "log.dat", "aa" )
        logcurrtime.write( " [Current Time:  %(currtime)s]" % vars() )
        logcurrtime.close()

        int (a)
        sleeptime =3D a * 60
        int (sleeptime)
       =20
        logsleeptime =3D open( "log.dat", "aa" )
        logsleeptime.write( " [Sleep Time:  %(sleeptime)s Mins.]" %
        vars() )
        logsleeptime.close()
       =20
        time.sleep( sleeptime )
        print "Set Time Complete"

        comptime =3D time.strftime( "%I:%M:%S%p %Z" )

        logcomptime =3D open( "log.dat", "aa" )
        logcomptime.write( " [Time Completed:  %(comptime)s]" % vars()
        )
        logcomptime.close()
       =20
        print "Completed at %(comptime)s." % vars()
        print "This window will close in 60 seconds."

        time.sleep(60)
        sys.exit()
       =20
    if begin.lower in "n no".split():
        print "FAILED"
        print "This window will close in 60 seconds."
       =20
        time.sleep( 60 )
        sys.exit()

name =3D raw_input( "Please type your name:  " )

logname =3D open( "log.dat", "aa" )
logname.write( "[Name:  %(name)s]" % vars() )
logname.close()

if name.lower() in "kyle jason chelsea john cheryl".split():
    while 1:
        print
        tosleep =3D raw_input( "Enter time to sleep in minutes:  " )
       =20
        confirm =3D raw_input( "Confirm %(tosleep)s minutes [Y/N]:  " %
        vars() )
       =20
        if confirm.lower() in "y yes".split():
            int( tosleep )
            sleep( tosleep )

else:
    print "FAILED"
    print "This window will close in 60 seconds."
   =20
    time.sleep( 60 )
    sys.exit()

##########################################################

Thank you,
--
Kyle