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
diff --git a/git_config.py b/git_config.py
index 19c19f1..289a5b6 100644
--- a/git_config.py
+++ b/git_config.py
@@ -563,6 +563,12 @@
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)