diff options
author | Shawn O. Pearce <sop@google.com> | 2011-09-11 12:57:15 -0700 |
---|---|---|
committer | Shawn O. Pearce <sop@google.com> | 2011-09-11 13:11:04 -0700 |
commit | 014d0609899dba70a1af0b32de377ca08c54aded (patch) | |
tree | cffe8353d15a9cf3ab03f3c2e8f244570650fbb4 /main.py | |
parent | 44da16e8a0e919c60a6eb7b5503cf915864d7336 (diff) | |
download | git-repo-014d0609899dba70a1af0b32de377ca08c54aded.tar.gz |
Honor http_proxy variable globally
If the http_proxy environment variable was set, honor it during
the entire repo session for any Python created HTTP connections.
Change-Id: Ib4ae833cb2cdd47ab0126949f6b399d2c142887d
Signed-off-by: Shawn O. Pearce <sop@google.com>
Diffstat (limited to 'main.py')
-rwxr-xr-x | main.py | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -26,6 +26,7 @@ import optparse | |||
26 | import os | 26 | import os |
27 | import re | 27 | import re |
28 | import sys | 28 | import sys |
29 | import urllib2 | ||
29 | 30 | ||
30 | from trace import SetTrace | 31 | from trace import SetTrace |
31 | from git_config import init_ssh, close_ssh | 32 | from git_config import init_ssh, close_ssh |
@@ -199,6 +200,12 @@ def _PruneOptions(argv, opt): | |||
199 | continue | 200 | continue |
200 | i += 1 | 201 | i += 1 |
201 | 202 | ||
203 | def init_http(): | ||
204 | if 'http_proxy' in os.environ: | ||
205 | url = os.environ['http_proxy'] | ||
206 | proxy_support = urllib2.ProxyHandler({'http': url, 'https': url}) | ||
207 | urllib2.install_opener(urllib2.build_opener(proxy_support)) | ||
208 | |||
202 | def _Main(argv): | 209 | def _Main(argv): |
203 | opt = optparse.OptionParser(usage="repo wrapperinfo -- ...") | 210 | opt = optparse.OptionParser(usage="repo wrapperinfo -- ...") |
204 | opt.add_option("--repo-dir", dest="repodir", | 211 | opt.add_option("--repo-dir", dest="repodir", |
@@ -217,6 +224,7 @@ def _Main(argv): | |||
217 | try: | 224 | try: |
218 | try: | 225 | try: |
219 | init_ssh() | 226 | init_ssh() |
227 | init_http() | ||
220 | repo._Run(argv) | 228 | repo._Run(argv) |
221 | finally: | 229 | finally: |
222 | close_ssh() | 230 | close_ssh() |