Fix SHA256 mismatch when downloading with chunked transfer enconding
Switch to urllib2, urllib doesn't support chunked.
This commit is contained in:
parent
7c436e7632
commit
a9b8ab94d9
13
hererocks.py
13
hererocks.py
@ -20,9 +20,9 @@ import tempfile
|
||||
import zipfile
|
||||
|
||||
try:
|
||||
from urllib import urlretrieve
|
||||
from urllib2 import urlopen
|
||||
except ImportError:
|
||||
from urllib.request import urlretrieve
|
||||
from urllib.request import urlopen
|
||||
|
||||
if os.name == "nt":
|
||||
try:
|
||||
@ -98,6 +98,13 @@ def get_default_cache():
|
||||
else:
|
||||
return os.path.join(home, ".cache", "hererocks")
|
||||
|
||||
def download(url, filename):
|
||||
response = urlopen(url)
|
||||
data = response.read()
|
||||
|
||||
with open(filename, "wb") as out:
|
||||
out.write(data)
|
||||
|
||||
def run(*args, **kwargs):
|
||||
"""Execute a command.
|
||||
|
||||
@ -394,7 +401,7 @@ class Program(object):
|
||||
|
||||
if not opts.downloads or not os.path.exists(archive_name):
|
||||
print(message)
|
||||
urlretrieve(url, archive_name)
|
||||
download(url, archive_name)
|
||||
else:
|
||||
print(message + " (cached)")
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user