aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake/lib
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/lib
parentbbc6e754e84115099722c78259868ee0e64bdc3c (diff)
downloadopenembedded-core-contrib-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/lib')
-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
from contextlib import contextmanager
from ctypes import cdll
-
logger = logging.getLogger("BitBake.Util")
python_extensions = [e for e, _, _ in imp.get_suffixes()]
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):
assert self.apiurl is not None
from django.db import transaction, connection
- import urllib2, urlparse, json
+ import json
import os
+
+ try:
+ from urllib.request import urlopen, URLError
+ from urllib.parse import urlparse
+ except ImportError:
+ from urllib2 import urlopen, URLError
+ from urlparse import urlparse
+
proxy_settings = os.environ.get("http_proxy", None)
oe_core_layer = 'openembedded-core'
def _get_json_response(apiurl = self.apiurl):
- _parsedurl = urlparse.urlparse(apiurl)
+ _parsedurl = urlparse(apiurl)
path = _parsedurl.path
try:
- res = urllib2.urlopen(apiurl)
- except urllib2.URLError as e:
+ res = urlopen(apiurl)
+ except URLError as e:
raise Exception("Failed to read %s: %s" % (path, e.reason))
return json.loads(res.read())