summaryrefslogtreecommitdiff
path: root/scripts/lib/recipetool
diff options
context:
space:
mode:
authorEd Bartosh <ed.bartosh@linux.intel.com>2016-05-18 21:57:23 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-02 08:10:03 +0100
commit30d02e2aa2d42fdf76271234b2dc9f37bc46b250 (patch)
tree2894bf5b42b389ef8dc5875163d2368e82534c69 /scripts/lib/recipetool
parente8cfab060f4ff3c4c16387871354d407910e87aa (diff)
downloadopenembedded-core-30d02e2aa2d42fdf76271234b2dc9f37bc46b250.tar.gz
openembedded-core-30d02e2aa2d42fdf76271234b2dc9f37bc46b250.tar.bz2
openembedded-core-30d02e2aa2d42fdf76271234b2dc9f37bc46b250.zip
scripts: Fix encoding errors for python3
Moved call of decode('utf-8') as close as possible to call of subprocess API to avoid calling it in a lot of other places. Decoded binary data to utf-8 where appropriate to fix devtool and recipetool tests in python 3 environment. Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Diffstat (limited to 'scripts/lib/recipetool')
-rw-r--r--scripts/lib/recipetool/append.py4
-rw-r--r--scripts/lib/recipetool/create.py4
-rw-r--r--scripts/lib/recipetool/create_buildsys_python.py2
3 files changed, 5 insertions, 5 deletions
diff --git a/scripts/lib/recipetool/append.py b/scripts/lib/recipetool/append.py
index 35756b08af..5d73d307e0 100644
--- a/scripts/lib/recipetool/append.py
+++ b/scripts/lib/recipetool/append.py
@@ -90,7 +90,7 @@ def find_target_file(targetpath, d, pkglist=None):
if fnmatch.fnmatchcase(fullpth, targetpath):
recipes[targetpath].append(pn)
elif line.startswith('pkg_preinst_') or line.startswith('pkg_postinst_'):
- scriptval = line.split(':', 1)[1].strip().decode('string_escape')
+ scriptval = line.split(':', 1)[1].strip().encode('utf-8').decode('unicode_escape')
if 'update-alternatives --install %s ' % targetpath in scriptval:
recipes[targetpath].append('?%s' % pn)
elif targetpath_re.search(scriptval):
@@ -172,7 +172,7 @@ def get_source_path(cmdelements):
"""Find the source path specified within a command"""
command = cmdelements[0]
if command in ['install', 'cp']:
- helptext = subprocess.check_output('LC_ALL=C %s --help' % command, shell=True)
+ helptext = subprocess.check_output('LC_ALL=C %s --help' % command, shell=True).decode('utf-8')
argopts = ''
argopt_line_re = re.compile('^-([a-zA-Z0-9]), --[a-z-]+=')
for line in helptext.splitlines():
diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py
index e3e01e385a..744ff1b0ab 100644
--- a/scripts/lib/recipetool/create.py
+++ b/scripts/lib/recipetool/create.py
@@ -851,14 +851,14 @@ def crunch_license(licfile):
continue
# Squash spaces, and replace smart quotes, double quotes
# and backticks with single quotes
- line = oe.utils.squashspaces(line.strip()).decode("utf-8")
+ line = oe.utils.squashspaces(line.strip())
line = line.replace(u"\u2018", "'").replace(u"\u2019", "'").replace(u"\u201c","'").replace(u"\u201d", "'").replace('"', '\'').replace('`', '\'')
if line:
lictext.append(line)
m = hashlib.md5()
try:
- m.update(' '.join(lictext))
+ m.update(' '.join(lictext).encode('utf-8'))
md5val = m.hexdigest()
except UnicodeEncodeError:
md5val = None
diff --git a/scripts/lib/recipetool/create_buildsys_python.py b/scripts/lib/recipetool/create_buildsys_python.py
index 5cbea2abba..55cce0e942 100644
--- a/scripts/lib/recipetool/create_buildsys_python.py
+++ b/scripts/lib/recipetool/create_buildsys_python.py
@@ -516,7 +516,7 @@ class PythonRecipeHandler(RecipeHandler):
except (OSError, subprocess.CalledProcessError):
pass
else:
- for line in dep_output.splitlines():
+ for line in dep_output.decode('utf-8').splitlines():
line = line.rstrip()
dep, filename = line.split('\t', 1)
if filename.endswith('/setup.py'):