diff options
-rw-r--r-- | python/servo/bootstrap_commands.py | 6 | ||||
-rw-r--r-- | python/servo/command_base.py | 10 | ||||
-rw-r--r-- | python/servo/devenv_commands.py | 5 | ||||
-rw-r--r-- | python/servo/util.py | 16 |
4 files changed, 22 insertions, 15 deletions
diff --git a/python/servo/bootstrap_commands.py b/python/servo/bootstrap_commands.py index 46328563247..aa64060ecaa 100644 --- a/python/servo/bootstrap_commands.py +++ b/python/servo/bootstrap_commands.py @@ -27,8 +27,9 @@ from mach.decorators import ( ) import servo.bootstrap as bootstrap -from servo.command_base import CommandBase, BIN_SUFFIX, cd, STATIC_RUST_LANG_ORG_DIST +from servo.command_base import CommandBase, BIN_SUFFIX, cd from servo.util import delete, download_bytes, download_file, extract, host_triple +from servo.util import STATIC_RUST_LANG_ORG_DIST, URLOPEN_KWARGS @CommandProvider @@ -94,7 +95,8 @@ class MachCommands(CommandBase): else: import toml channel = nightly_dist + "/channel-rust-nightly.toml" - nightly_commit_hash = toml.load(urllib2.urlopen(channel))["pkg"]["rustc"]["git_commit_hash"] + manifest = toml.load(urllib2.urlopen(channel, **URLOPEN_KWARGS)) + nightly_commit_hash = manifest["pkg"]["rustc"]["git_commit_hash"] base_url = "https://s3.amazonaws.com/rust-lang-ci/rustc-builds-alt/" + nightly_commit_hash diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 1eaf09411e3..77bb88886fa 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -25,16 +25,6 @@ import toml from servo.packages import WINDOWS_MSVC as msvc_deps from servo.util import host_triple, host_platform -try: - from ssl import HAS_SNI -except ImportError: - HAS_SNI = False - -if HAS_SNI: - STATIC_RUST_LANG_ORG_DIST = "https://static.rust-lang.org/dist" -else: - STATIC_RUST_LANG_ORG_DIST = "https://static-rust-lang-org.s3.amazonaws.com/dist" - BIN_SUFFIX = ".exe" if sys.platform == "win32" else "" diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py index 8f51cfcc44d..e6cb91bd20a 100644 --- a/python/servo/devenv_commands.py +++ b/python/servo/devenv_commands.py @@ -21,8 +21,9 @@ from mach.decorators import ( Command, ) -from servo.command_base import CommandBase, cd, call, STATIC_RUST_LANG_ORG_DIST +from servo.command_base import CommandBase, cd, call from servo.build_commands import notify_build_done +from servo.util import STATIC_RUST_LANG_ORG_DIST, URLOPEN_KWARGS @CommandProvider @@ -263,7 +264,7 @@ class MachCommands(CommandBase): category='devenv') def rustup(self): url = STATIC_RUST_LANG_ORG_DIST + "/channel-rust-nightly-date.txt" - nightly_date = urllib2.urlopen(url).read() + nightly_date = urllib2.urlopen(url, **URLOPEN_KWARGS).read() filename = path.join(self.context.topdir, "rust-toolchain") with open(filename, "w") as f: f.write("nightly-%s\n" % nightly_date) diff --git a/python/servo/util.py b/python/servo/util.py index 485637b81f1..78158b840da 100644 --- a/python/servo/util.py +++ b/python/servo/util.py @@ -22,6 +22,20 @@ import urllib2 import certifi +try: + from ssl import HAS_SNI +except ImportError: + HAS_SNI = False + +# The cafile parameter was added in 2.7.9 +if HAS_SNI and sys.version_info >= (2, 7, 9): + STATIC_RUST_LANG_ORG_DIST = "https://static.rust-lang.org/dist" + URLOPEN_KWARGS = {"cafile": certifi.where()} +else: + STATIC_RUST_LANG_ORG_DIST = "https://static-rust-lang-org.s3.amazonaws.com/dist" + URLOPEN_KWARGS = {} + + def delete(path): if os.path.isdir(path) and not os.path.islink(path): shutil.rmtree(path) @@ -74,7 +88,7 @@ def download(desc, src, writer, start_byte=0): req = urllib2.Request(src) if start_byte: req = urllib2.Request(src, headers={'Range': 'bytes={}-'.format(start_byte)}) - resp = urllib2.urlopen(req, cafile=certifi.where()) + resp = urllib2.urlopen(req, **URLOPEN_KWARGS) fsize = None if resp.info().getheader('Content-Length'): |