[Tutor] problems with time.sleep()

Bunting, Glen, IG (x) GBunting864@Worldsavings.com
Wed, 20 Jun 2001 11:59:16 -0500


Hi,

Below is a script that I am trying to write.  Basically it grabs a url and
downloads a file, calculates the speed of the download and place the speed
and time in a dictionary.  The next step to figure out a way to use Tkinter
to graph the results.  The problem I'm getting is it is not printing out the
list that is in the dictionary, and gives no error for that, and the
time.sleep() function fails.  I am on windows NT using ActivePython.  The
script, output, and errors are below.  Any improvements would be
appreciated.

Thanks
Glen


#!/usr/bin/env python

import os, urllib
from time import *

def updateSpeedvar():
        while 1:
                import time
                first = time.time()
                print first
 
urllib.urlretrieve('http://theworks.tucows.com/files3/cooolftp.exe',
                           'test')
                second = time.time()
                print second
                final = second - first
                print final
                speed1 = 1622/final
                speed = round(speed1, 1)
                print speed
                time = strftime("%X", localtime())
                print time
                dict = {time:speed}
                dict.items()
                time.sleep(180)
        


if __name__=='__main__':
    updateSpeedvar()


>>> 993055818.748
993055819.018
0.269999980927
6007.4
09:50:19
Traceback (most recent call last):
  File "c:\python21\pythonwin\pywin\framework\scriptutils.py", line 301, in
RunScript
    exec codeObject in __main__.__dict__
  File "C:\python\bandwidth3.py", line 30, in ?
    updateSpeedvar()
  File "C:\python\bandwidth3.py", line 25, in updateSpeedvar
    time.sleep(180)
AttributeError: sleep


*****************************************************************************
If you are not the intended recipient of this e-mail, please notify 
the sender immediately. The contents of this e-mail do not amend 
any existing disclosures or agreements unless expressly stated.
*****************************************************************************