summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-05-10 14:35:55 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-02 08:24:03 +0100
commit0224f7599995166e15d1ea2d1b0e6155f5026a18 (patch)
treebc7ca4c37680a63a2faee8679cdc4de0fcba4fc5 /bitbake
parentbbc6e754e84115099722c78259868ee0e64bdc3c (diff)
downloadpoky-0224f7599995166e15d1ea2d1b0e6155f5026a18.tar.gz
bitbake: toaster: fix imports to work for python 3
Some APIs have been moved to other modules in python 3: getstatusoutput: moved from commands to subproces urlopen: moved from urllib2 to urllib.request urlparse: moved from urlparse to urllib.parse Made the imports work for both python versions by catching ImportError and importing APIs from different modules. [YOCTO #9584] (Bitbake rev: 1abaa1c6a950b327e6468192dd910549643768bb) Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/utils.py1
-rw-r--r--bitbake/lib/toaster/orm/models.py16
2 files changed, 12 insertions, 5 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 138da44ef1..8f75871c18 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -41,7 +41,6 @@ from subprocess import getstatusoutput
41from contextlib import contextmanager 41from contextlib import contextmanager
42from ctypes import cdll 42from ctypes import cdll
43 43
44
45logger = logging.getLogger("BitBake.Util") 44logger = logging.getLogger("BitBake.Util")
46python_extensions = [e for e, _, _ in imp.get_suffixes()] 45python_extensions = [e for e, _, _ in imp.get_suffixes()]
47 46
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 88967a23f5..9183b0cd7c 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -1147,18 +1147,26 @@ class LayerIndexLayerSource(LayerSource):
1147 assert self.apiurl is not None 1147 assert self.apiurl is not None
1148 from django.db import transaction, connection 1148 from django.db import transaction, connection
1149 1149
1150 import urllib2, urlparse, json 1150 import json
1151 import os 1151 import os
1152
1153 try:
1154 from urllib.request import urlopen, URLError
1155 from urllib.parse import urlparse
1156 except ImportError:
1157 from urllib2 import urlopen, URLError
1158 from urlparse import urlparse
1159
1152 proxy_settings = os.environ.get("http_proxy", None) 1160 proxy_settings = os.environ.get("http_proxy", None)
1153 oe_core_layer = 'openembedded-core' 1161 oe_core_layer = 'openembedded-core'
1154 1162
1155 def _get_json_response(apiurl = self.apiurl): 1163 def _get_json_response(apiurl = self.apiurl):
1156 _parsedurl = urlparse.urlparse(apiurl) 1164 _parsedurl = urlparse(apiurl)
1157 path = _parsedurl.path 1165 path = _parsedurl.path
1158 1166
1159 try: 1167 try:
1160 res = urllib2.urlopen(apiurl) 1168 res = urlopen(apiurl)
1161 except urllib2.URLError as e: 1169 except URLError as e:
1162 raise Exception("Failed to read %s: %s" % (path, e.reason)) 1170 raise Exception("Failed to read %s: %s" % (path, e.reason))
1163 1171
1164 return json.loads(res.read()) 1172 return json.loads(res.read())