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
|
import zipfile
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from urllib import urlretrieve
|
from urllib2 import urlopen
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from urllib.request import urlretrieve
|
from urllib.request import urlopen
|
||||||
|
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
try:
|
try:
|
||||||
@ -98,6 +98,13 @@ def get_default_cache():
|
|||||||
else:
|
else:
|
||||||
return os.path.join(home, ".cache", "hererocks")
|
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):
|
def run(*args, **kwargs):
|
||||||
"""Execute a command.
|
"""Execute a command.
|
||||||
|
|
||||||
@ -394,7 +401,7 @@ class Program(object):
|
|||||||
|
|
||||||
if not opts.downloads or not os.path.exists(archive_name):
|
if not opts.downloads or not os.path.exists(archive_name):
|
||||||
print(message)
|
print(message)
|
||||||
urlretrieve(url, archive_name)
|
download(url, archive_name)
|
||||||
else:
|
else:
|
||||||
print(message + " (cached)")
|
print(message + " (cached)")
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user