hi again!:)
when i use urllib.urlretreive(somthing,local_somthing)
it crushs cpu,comp.
what can i do?
sorrry for my english
that is code:
class UPDATE(wx.Frame):
def __init__(self):
pass
def Download(self):
wx.Frame.__init__(self,None,-1,"Downloading",(0,0),wx.Size(500,500))
panel=wx.Panel(self,-1)
self.gauge = wx.Gauge(panel, 57, 100,(100,100), size=(250, 25))
wx.StaticText(panel,-1,"downloading please wait..",pos=(0,0))
self.Show()
self.geturl("http://vpython.org/contents/download/VPython-Win-Py2.5-5.11.exe","hoho")
def _reporthook(self,numblocks, blocksize, filesize, url=None):
#print "reporthook(%s, %s, %s)" % (numblocks, blocksize, filesize)
base = os.path.basename(url)
#XXX Should handle possible filesize=-1.
try:
percent = min((numblocks*blocksize*100)/filesize, 100)
except:
percent = 100
if numblocks != 0:
sys.stdout.write("\b"*70)
self.gauge.SetValue(percent)
sys.stdout.write("%-66s%3d%%" % (base, percent))
def geturl(self,url, dst):
print "get url '%s' to '%s'" % (url, dst)
if sys.stdout.isatty():
urllib.urlretrieve(url, dst,
lambda nb, bs, fs, url=url: self._reporthook(nb,bs,fs,url))
sys.stdout.write('\n')
else:
urllib.urlretrieve(url, dst)