remove dependency on wget for 'build' and 'verify'

To make the core tools portable to platforms like Mac OS X and Windows,
remove the dependency on wget and instead use Python Requests, which
probably has better performance anyway.
This commit is contained in:
Hans-Christoph Steiner 2015-07-23 21:42:21 -07:00
parent cef7553873
commit f625005ec3
4 changed files with 19 additions and 7 deletions

View file

@ -22,6 +22,7 @@ import sys
import re
import shutil
import glob
import requests
import stat
import subprocess
import time
@ -2070,3 +2071,17 @@ def string_is_integer(string):
return True
except ValueError:
return False
def download_file(url, local_filename=None, dldir='tmp'):
filename = url.split('/')[-1]
if local_filename is None:
local_filename = os.path.join(dldir, filename)
# the stream=True parameter keeps memory usage low
r = requests.get(url, stream=True)
with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
f.flush()
return local_filename