build: use python3 to download external binaries (#21184)

* build: use python3 to download external binaries

* Update config.py
This commit is contained in:
Samuel Attard 2019-11-19 06:08:20 -08:00 committed by John Kleinschmidt
parent 73467f00e3
commit d34ba76eb6
3 changed files with 13 additions and 4 deletions

2
DEPS
View file

@ -114,7 +114,7 @@ hooks = [
'pattern': 'src/electron/script/update-external-binaries.py',
'condition': 'download_external_binaries',
'action': [
'python',
'python3',
'src/electron/script/update-external-binaries.py',
],
},

View file

@ -21,6 +21,7 @@ BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \
PLATFORM = {
'cygwin': 'win32',
'darwin': 'darwin',
'linux': 'linux',
'linux2': 'linux',
'win32': 'win32',
}[sys.platform]

View file

@ -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