From a101f1c1670c9992c28980a7028dc6c60028af69 Mon Sep 17 00:00:00 2001 From: Anatol Pomozov Date: Fri, 8 Jul 2011 13:52:11 -0700 Subject: [PATCH] Honor 'http_proxy' environment variable 'repo upload' makes http request using urllib2 python library. Unfortunately this library does not work (by default) in case if the user behind a proxy. This change adds proxy handler in case if 'http_proxy' environment variable is set. Change-Id: Ic4176ad733fc21bd5b59661b3eacc2f0a7c3c1ff --- git_config.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/git_config.py b/git_config.py index 19c19f19..289a5b64 100644 --- a/git_config.py +++ b/git_config.py @@ -563,6 +563,12 @@ class Remote(object): self._review_port = info[2] else: try: + if 'http_proxy' in os.environ: + proxy_url = os.environ['http_proxy'] + proxy_support = urllib2.ProxyHandler({"http" : proxy_url, "https" : proxy_url}) + opener = urllib2.build_opener(proxy_support) + urllib2.install_opener(opener) + info = urlopen(u).read() if info == 'NOT_AVAILABLE': raise UploadError('%s: SSH disabled' % self.review)