aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/util.py
diff options
context:
space:
mode:
authormarmeladema <xademax@gmail.com>2019-10-14 00:36:20 +0100
committermarmeladema <xademax@gmail.com>2019-10-16 00:22:07 +0100
commitf1d42fe787c20ff2d62b0aab00874fe9c79af352 (patch)
tree7aacb29eb1243018d2610de3274ef0ac0edf665e /python/servo/util.py
parentf063ea64a5023aa95f7165ed46d87c43c1f52340 (diff)
downloadservo-f1d42fe787c20ff2d62b0aab00874fe9c79af352.tar.gz
servo-f1d42fe787c20ff2d62b0aab00874fe9c79af352.zip
Use urllib from six module in order to be compatible with Python3
Diffstat (limited to 'python/servo/util.py')
-rw-r--r--python/servo/util.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/python/servo/util.py b/python/servo/util.py
index 818240d39e6..f51b1f12252 100644
--- a/python/servo/util.py
+++ b/python/servo/util.py
@@ -20,7 +20,7 @@ import StringIO
import sys
import time
import zipfile
-import urllib2
+import six.moves.urllib as urllib
try:
@@ -101,10 +101,10 @@ def download(desc, src, writer, start_byte=0):
dumb = (os.environ.get("TERM") == "dumb") or (not sys.stdout.isatty())
try:
- req = urllib2.Request(src)
+ req = urllib.request.Request(src)
if start_byte:
- req = urllib2.Request(src, headers={'Range': 'bytes={}-'.format(start_byte)})
- resp = urllib2.urlopen(req, **get_urlopen_kwargs())
+ req = urllib.request.Request(src, headers={'Range': 'bytes={}-'.format(start_byte)})
+ resp = urllib.request.urlopen(req, **get_urlopen_kwargs())
fsize = None
if resp.info().getheader('Content-Length'):
@@ -136,13 +136,13 @@ def download(desc, src, writer, start_byte=0):
if not dumb:
print()
- except urllib2.HTTPError, e:
+ except urllib.error.HTTPError, e:
print("Download failed ({}): {} - {}".format(e.code, e.reason, src))
if e.code == 403:
print("No Rust compiler binary available for this platform. "
"Please see https://github.com/servo/servo/#prerequisites")
sys.exit(1)
- except urllib2.URLError, e:
+ except urllib.error.URLError, e:
print("Error downloading {}: {}. The failing URL was: {}".format(desc, e.reason, src))
sys.exit(1)
except socket_error, e: