diff --git a/git_config.py b/git_config.py index 289a5b64..19c19f19 100644 --- a/git_config.py +++ b/git_config.py @@ -563,12 +563,6 @@ 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) diff --git a/main.py b/main.py index f068fd47..48edc1cc 100755 --- a/main.py +++ b/main.py @@ -26,6 +26,7 @@ import optparse import os import re import sys +import urllib2 from trace import SetTrace from git_config import init_ssh, close_ssh @@ -199,6 +200,12 @@ def _PruneOptions(argv, opt): continue i += 1 +def init_http(): + if 'http_proxy' in os.environ: + url = os.environ['http_proxy'] + proxy_support = urllib2.ProxyHandler({'http': url, 'https': url}) + urllib2.install_opener(urllib2.build_opener(proxy_support)) + def _Main(argv): opt = optparse.OptionParser(usage="repo wrapperinfo -- ...") opt.add_option("--repo-dir", dest="repodir", @@ -217,6 +224,7 @@ def _Main(argv): try: try: init_ssh() + init_http() repo._Run(argv) finally: close_ssh()