summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/toaster/orm/models.py36
1 files changed, 7 insertions, 29 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 92fcaa7adf..58f76a8342 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -817,42 +817,20 @@ class LayerIndexLayerSource(LayerSource):
817 assert self.apiurl is not None 817 assert self.apiurl is not None
818 from django.db import transaction, connection 818 from django.db import transaction, connection
819 819
820 import httplib, urlparse, json 820 import urllib2, urlparse, json
821 import os 821 import os
822 proxy_settings = os.environ.get("http_proxy", None) 822 proxy_settings = os.environ.get("http_proxy", None)
823 823
824 def _get_json_response(apiurl = self.apiurl): 824 def _get_json_response(apiurl = self.apiurl):
825 conn = None
826 _parsedurl = urlparse.urlparse(apiurl) 825 _parsedurl = urlparse.urlparse(apiurl)
827 path = _parsedurl.path 826 path = _parsedurl.path
828 query = _parsedurl.query
829 def parse_url(url):
830 parsedurl = urlparse.urlparse(url)
831 try:
832 (host, port) = parsedurl.netloc.split(":")
833 except ValueError:
834 host = parsedurl.netloc
835 port = None
836
837 if port is None:
838 port = 80
839 else:
840 port = int(port)
841 return (host, port)
842 827
843 if proxy_settings is None: 828 try:
844 host, port = parse_url(apiurl) 829 res = urllib2.urlopen(apiurl)
845 conn = httplib.HTTPConnection(host, port) 830 except urllib2.URLError as e:
846 conn.request("GET", path + "?" + query) 831 raise Exception("Failed to read %s: %s" % (path, e.reason))
847 else: 832
848 host, port = parse_url(proxy_settings) 833 return json.loads(res.read())
849 conn = httplib.HTTPConnection(host, port)
850 conn.request("GET", apiurl)
851
852 r = conn.getresponse()
853 if r.status != 200:
854 raise Exception("Failed to read " + path + ": %d %s" % (r.status, r.reason))
855 return json.loads(r.read())
856 834
857 # verify we can get the basic api 835 # verify we can get the basic api
858 try: 836 try: