mirror of
https://git.yoctoproject.org/poky
synced 2026-04-20 18:32:12 +02:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
21924451c1
commit
49ac18dd0f
@@ -599,24 +599,41 @@ class LayerIndexLayerSource(LayerSource):
|
||||
assert self.apiurl is not None
|
||||
from django.db import IntegrityError
|
||||
|
||||
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
|
||||
import httplib, urlparse, json
|
||||
import os
|
||||
proxy_settings = os.environ.get("http_proxy", None)
|
||||
|
||||
if port is None:
|
||||
port = 80
|
||||
def _get_json_response(apiurl = self.apiurl):
|
||||
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 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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user