All pastes #126629 Raw Edit

pygetfile

public python v1 · immutable
·published 2006-08-11 17:36 UTC
rendered paste body
#!/usr/bin/python## pygetfile ver. 1.0## Download file# Usage:#   pygetfile URL#   ## (C) 2005 John Battles## This file is in public domain.# user-tunable parameters:maxRetries=10# The list of mirrors. Add new ones here.# end of user-tunable parametersimport random, urllib, sys, stat, time, os, stringurl=sys.argv[1]outputFile = sys.argv[2]print "Getting: "+url+" saving to: "+outputFilefor a in range(maxRetries):    try:        sys.stderr.write("Using %s\nDownloading...\n" % url)        urllib.urlretrieve(url, outputFile)        time.sleep(1.0)        break    except:        pass        # To tune add one sec to maxDownloadFrequencySecs = maxDownloadFrequencySecs - 1    pass