|
@@ -16,7 +16,11 @@ import subprocess
|
|
|
import sys
|
|
|
import tarfile
|
|
|
import tempfile
|
|
|
-import urllib2
|
|
|
+# Python 3 / 2 compat import
|
|
|
+try:
|
|
|
+ from urllib.request import urlopen
|
|
|
+except ImportError:
|
|
|
+ from urllib2 import urlopen
|
|
|
import zipfile
|
|
|
|
|
|
from lib.config import is_verbose_mode, PLATFORM
|
|
@@ -69,8 +73,12 @@ def download(text, url, path):
|
|
|
ssl._create_default_https_context = ssl._create_unverified_context
|
|
|
|
|
|
print("Downloading %s to %s" % (url, path))
|
|
|
- web_file = urllib2.urlopen(url)
|
|
|
- file_size = int(web_file.info().getheaders("Content-Length")[0])
|
|
|
+ web_file = urlopen(url)
|
|
|
+ info = web_file.info()
|
|
|
+ if hasattr(info, 'getheader'):
|
|
|
+ file_size = int(info.getheaders("Content-Length")[0])
|
|
|
+ else:
|
|
|
+ file_size = int(info.get("Content-Length")[0])
|
|
|
downloaded_size = 0
|
|
|
block_size = 4096
|
|
|
|