Created
November 14, 2012 14:15
-
-
Save 3ign0n/4072336 to your computer and use it in GitHub Desktop.
add proxy support to Tizen gbs(gitbuildsys)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- gitbuildsys/utils.py.orig 2012-11-14 22:23:01.000000000 +0900 | |
+++ gitbuildsys/utils.py 2012-11-15 07:33:56.000000000 +0900 | |
@@ -23,6 +23,7 @@ | |
import pycurl | |
import hashlib | |
import signal | |
+import re | |
import xml.etree.ElementTree as ET | |
from collections import defaultdict | |
@@ -164,6 +165,7 @@ | |
curl.setopt(pycurl.SSL_VERIFYHOST, False) | |
curl.setopt(pycurl.CONNECTTIMEOUT, connect_timeout) | |
#curl.setopt(pycurl.VERBOSE, 1) | |
+ self.set_proxy_opts(curl) | |
self.curl = curl | |
def change_url(self, url, outfile, user, passwd): | |
@@ -237,6 +239,16 @@ | |
self.change_url(url, outfile, user, passwd) | |
self.perform() | |
+ def set_proxy_opts(self, curl): | |
+ if os.environ.has_key("http_proxy"): | |
+ http_proxy = os.environ["http_proxy"] | |
+ m = re.search('^http://(([\w]+:[\w]+){0,1}@){0,1}([\w\.]+)(:([0-9]{1,5})){0,1}', http_proxy) | |
+ if m.group(2): | |
+ curl.setopt(pycurl.USERPWD, m.group(2)) | |
+ if m.group(3): | |
+ curl.setopt(pycurl.PROXY, m.group(3)) | |
+ if m.group(5): | |
+ curl.setopt(pycurl.PROXYPORT, int(m.group(5))) | |
class RepoParser(object): | |
""" Repository parser for generate real repourl and build config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment