From f1d42fe787c20ff2d62b0aab00874fe9c79af352 Mon Sep 17 00:00:00 2001 From: marmeladema Date: Mon, 14 Oct 2019 00:36:20 +0100 Subject: Use urllib from six module in order to be compatible with Python3 --- python/servo/command_base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'python/servo/command_base.py') diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 67f91e6a1d4..176ecd89e48 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -27,7 +27,7 @@ import tarfile import zipfile from xml.etree.ElementTree import XML from servo.util import download_file -import urllib2 +import six.moves.urllib as urllib from bootstrap import check_gstreamer_lib from mach.decorators import CommandArgument @@ -506,15 +506,15 @@ class CommandBase(object): nightly_date = nightly_date.strip() # Fetch the filename to download from the build list repository_index = NIGHTLY_REPOSITORY_URL + "?list-type=2&prefix=nightly" - req = urllib2.Request( + req = urllib.request.Request( "{}/{}/{}".format(repository_index, os_prefix, nightly_date)) try: - response = urllib2.urlopen(req).read() + response = urllib.request.urlopen(req).read() tree = XML(response) namespaces = {'ns': tree.tag[1:tree.tag.index('}')]} file_to_download = tree.find('ns:Contents', namespaces).find( 'ns:Key', namespaces).text - except urllib2.URLError as e: + except urllib.error.URLError as e: print("Could not fetch the available nightly versions from the repository : {}".format( e.reason)) sys.exit(1) -- cgit v1.2.3