ScRapZ_1
09-11-2002, 11:23 AM
And now for a better description ;)
I'm writing a sort of download manager in python. I've got nearly everything worked out except for this. When I download a file using urllib.urlretrieve() it happily downloads the file, but overwrites whatever had already been previously downloaded. Which means re-downloading everything all over again. Is it possible to start downloading from an offset? What I'm thinking is using os.stat() to find the filesize, then pass that through as the offset to start downloading. There doesnt seem to be anything in the docs about urlretrieve doing this, and I cant find anything suitable. Is there something I can hack up, or another module that can do what I want it to?
from urllib import urlretrieve as getfile
def sofar(numblock, blocksize, totalsize):
print "%i of %i so far" % ((numblock*blocksize)/1024, totalsize/1024)
getfile(remote,local,sofar)
TTFN,
Scrapz :p
I'm writing a sort of download manager in python. I've got nearly everything worked out except for this. When I download a file using urllib.urlretrieve() it happily downloads the file, but overwrites whatever had already been previously downloaded. Which means re-downloading everything all over again. Is it possible to start downloading from an offset? What I'm thinking is using os.stat() to find the filesize, then pass that through as the offset to start downloading. There doesnt seem to be anything in the docs about urlretrieve doing this, and I cant find anything suitable. Is there something I can hack up, or another module that can do what I want it to?
from urllib import urlretrieve as getfile
def sofar(numblock, blocksize, totalsize):
print "%i of %i so far" % ((numblock*blocksize)/1024, totalsize/1024)
getfile(remote,local,sofar)
TTFN,
Scrapz :p