summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/orm/models.py
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-11-21 13:58:51 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-11-28 14:02:57 +0000
commit49ac18dd0fedbcb63e9b18d1b0df62431ed37eb0 (patch)
treecc753ee05a35c1a806e4ac9d626f014160b1638a /bitbake/lib/toaster/orm/models.py
parent21924451c10e058473c50c697c23d7149297856a (diff)
downloadast2050-yocto-poky-49ac18dd0fedbcb63e9b18d1b0df62431ed37eb0.zip
ast2050-yocto-poky-49ac18dd0fedbcb63e9b18d1b0df62431ed37eb0.tar.gz
bitbake: toaster: use http proxies to fetch data
Under some network configurations http proxies are used for Internet access. This patch makes Toaster obey the http_proxy environment variable when fetching information from layer indexes. (Bitbake rev: 9f3cf52b3a96768e5b9764dde02833b078fe61e4) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/orm/models.py')
-rw-r--r--bitbake/lib/toaster/orm/models.py45
1 files changed, 32 insertions, 13 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index c90e047..99cc695 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -599,24 +599,41 @@ class LayerIndexLayerSource(LayerSource):
assert self.apiurl is not None
from django.db import IntegrityError
+ import httplib, urlparse, json
+ import os
+ proxy_settings = os.environ.get("http_proxy", None)
+
def _get_json_response(apiurl = self.apiurl):
- import httplib, urlparse, json
- parsedurl = urlparse.urlparse(apiurl)
- try:
- (host, port) = parsedurl.netloc.split(":")
- except ValueError:
- host = parsedurl.netloc
- port = None
+ conn = None
+ _parsedurl = urlparse.urlparse(apiurl)
+ path = _parsedurl.path
+ query = _parsedurl.query
+ def parse_url(url):
+ parsedurl = urlparse.urlparse(url)
+ try:
+ (host, port) = parsedurl.netloc.split(":")
+ except ValueError:
+ host = parsedurl.netloc
+ port = None
+
+ if port is None:
+ port = 80
+ else:
+ port = int(port)
+ return (host, port)
- if port is None:
- port = 80
+ if proxy_settings is None:
+ host, port = parse_url(apiurl)
+ conn = httplib.HTTPConnection(host, port)
+ conn.request("GET", path + "?" + query)
else:
- port = int(port)
- conn = httplib.HTTPConnection(host, port)
- conn.request("GET", parsedurl.path + "?" + parsedurl.query)
+ host, port = parse_url(proxy_settings)
+ conn = httplib.HTTPConnection(host, port)
+ conn.request("GET", apiurl)
+
r = conn.getresponse()
if r.status != 200:
- raise Exception("Failed to read " + parsedurl.path + ": %d %s" % (r.status, r.reason))
+ raise Exception("Failed to read " + path + ": %d %s" % (r.status, r.reason))
return json.loads(r.read())
# verify we can get the basic api
@@ -624,6 +641,8 @@ class LayerIndexLayerSource(LayerSource):
apilinks = _get_json_response()
except Exception as e:
import traceback
+ if proxy_settings is not None:
+ print "EE: Using proxy ", proxy_settings
print "EE: could not connect to %s, skipping update: %s\n%s" % (self.apiurl, e, traceback.format_exc(e))
return
OpenPOWER on IntegriCloud