aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2018-03-01 08:26:57 +1300
committerPaul Eggleton <paul.eggleton@linux.intel.com>2018-05-04 23:57:52 +1200
commitaad000734c8ae9bd1cca311469c62bae8a1aa1cd (patch)
treee47deff0b6a8490da7068b2542b4bfe36fea65ec
parentedb1261d2bcc23d34bc074e7fdf4e1efe63230de (diff)
downloadopenembedded-core-contrib-aad000734c8ae9bd1cca311469c62bae8a1aa1cd.tar.gz
utils: decode command output in runcmd() as UTF-8
Sometimes we get back UTF-8 characters (particularly when picking up names from git commits), and the ascii codec will error out if that happens, so switch over to utf-8. We can as a result remove the decode() calls from the bulk change view. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
-rw-r--r--layerindex/utils.py4
-rw-r--r--layerindex/views.py3
2 files changed, 3 insertions, 4 deletions
diff --git a/layerindex/utils.py b/layerindex/utils.py
index 093ba140ca..db5bfc662e 100644
--- a/layerindex/utils.py
+++ b/layerindex/utils.py
@@ -264,7 +264,7 @@ def runcmd(cmd, destdir=None, printerr=True, logger=None):
except subprocess.CalledProcessError as e:
out.seek(0)
output = out.read()
- output = output.decode('ascii').strip()
+ output = output.decode('utf-8', errors='replace').strip()
if printerr:
if logger:
logger.error("%s" % output)
@@ -275,7 +275,7 @@ def runcmd(cmd, destdir=None, printerr=True, logger=None):
out.seek(0)
output = out.read()
- output = output.decode('ascii').strip()
+ output = output.decode('utf-8', errors='replace').strip()
if logger:
logger.debug("output: %s" % output.rstrip() )
return output
diff --git a/layerindex/views.py b/layerindex/views.py
index bc3cddfa83..74cccd589c 100644
--- a/layerindex/views.py
+++ b/layerindex/views.py
@@ -224,7 +224,7 @@ def bulk_change_patch_view(request, pk):
try:
ret = utils.runcmd('%s bulkchange.py %d %s' % (sys.executable, int(pk), settings.TEMP_BASE_DIR), os.path.dirname(__file__))
if ret:
- fn = ret.splitlines()[-1].decode('utf-8')
+ fn = ret.splitlines()[-1]
if os.path.exists(fn):
if fn.endswith('.tar.gz'):
mimetype = 'application/x-gzip'
@@ -241,7 +241,6 @@ def bulk_change_patch_view(request, pk):
except Exception as e:
output = getattr(e, 'output', None)
if output:
- output = output.decode('utf-8', errors="ignore")
if 'timeout' in output:
return HttpResponse('Failed to generate patches: timed out waiting for lock. Please try again shortly.', content_type='text/plain')
else: