From 48d6059a5f4039ea13a0e08549acb552ff3de83a Mon Sep 17 00:00:00 2001 From: Darragh Bailey Date: Tue, 5 May 2015 15:27:40 +0100 Subject: [PATCH] Switch to requests to support proxying of 'https' Convert to using the requests module which supports proxying of 'https' connections for retriving the gerrit war file when behind a corporate proxy. Change-Id: Id368cb6aa7058970ad6ac10caacea2aec9bfe48b --- git_review/tests/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/git_review/tests/__init__.py b/git_review/tests/__init__.py index dc2d894..444e44a 100644 --- a/git_review/tests/__init__.py +++ b/git_review/tests/__init__.py @@ -21,15 +21,14 @@ import sys if sys.version < '3': import urllib import urlparse - urlopen = urllib.urlopen urlparse = urlparse.urlparse else: import urllib.parse import urllib.request - urlopen = urllib.request.urlopen urlparse = urllib.parse.urlparse import fixtures +import requests import testtools from testtools import content @@ -60,8 +59,10 @@ class GerritHelpers(object): if not os.path.exists(self.gerrit_war): print("Downloading Gerrit binary from %s..." % WAR_URL) - resp = urlopen(WAR_URL) - utils.write_to_file(self.gerrit_war, resp.read()) + resp = requests.get(WAR_URL) + if resp.status_code != 200: + raise RuntimeError("Problem requesting Gerrit war") + utils.write_to_file(self.gerrit_war, resp.content) print("Saved to %s" % self.gerrit_war) def init_gerrit(self):