diff options
author | Manuel Kaufmann <humitos@gmail.com> | 2012-10-18 14:33:07 (GMT) |
---|---|---|
committer | Manuel Kaufmann <humitos@gmail.com> | 2012-10-18 14:33:07 (GMT) |
commit | 4fbd0469e5440888b4ad9f6f04f28e66aaa3d142 (patch) | |
tree | e8b7efca6b81280a53a3e0ac09ef43f8aff372c1 | |
parent | 6904b1fa4a99700f47cb2bce388c837c00aa195c (diff) |
Use wget to download the files Help
It support Pause / Resume downloads :)
-rw-r--r-- | scripts/download_latest_release.py | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/scripts/download_latest_release.py b/scripts/download_latest_release.py index d32ddfb..cd2a472 100644 --- a/scripts/download_latest_release.py +++ b/scripts/download_latest_release.py @@ -14,18 +14,13 @@ except ImportError: sys.exit(1) -# http://code.activestate.com/recipes/576530-download-a-url-with-a-console-progress-meter/ -def _reporthook(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) - sys.stdout.write("%-66s%3d%%" % (base, percent)) +WGET_CMD = 'wget --continue %(url)s -O %(output_filename)s' +def download_file(url, output_filename): + data = { + 'url': url, + 'output_filename': output_filename, + } + os.system(WGET_CMD % data) # TODO: pass version via argument @@ -64,10 +59,10 @@ for v in XO_VERSIONS: print 'OUTPUT_PATH:', output_filename - if os.path.exists(output_filename): - print 'Already downloaded, skipping...' - print - continue + # if os.path.exists(output_filename): + # print 'Already downloaded, skipping...' + # print + # continue url = FILE_URL % \ {'os': latest_os, @@ -77,8 +72,6 @@ for v in XO_VERSIONS: } print 'Downloading', url, '...' - urllib.urlretrieve( - url, output_filename, - lambda nb, bs, fs, url=url: _reporthook(nb, bs, fs, url)) + download_file(url, output_filename) print '\n\n' print 'DONE!' |