mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
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>
This commit is contained in:
parent
edb1261d2b
commit
aad000734c
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user