[yocto] [layerindex-web][PATCH 04/10] layerindex/utils: Update runcmd to decode binary strings to strings.
Liam R. Howlett
Liam.Howlett at windriver.com
Mon Sep 26 11:25:32 PDT 2016
Convert binary strings to strings and strip leading/trailing whitespace
prior to returning errors and output.
Signed-off-by: Liam R. Howlett <Liam.Howlett at WindRiver.com>
---
layerindex/utils.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/layerindex/utils.py b/layerindex/utils.py
index 50268e0..23b81f5 100644
--- a/layerindex/utils.py
+++ b/layerindex/utils.py
@@ -32,7 +32,8 @@ def runcmd(cmd, destdir=None, printerr=True, logger=None):
execute command, raise CalledProcessError if fail
return output if succeed
"""
- #logger.debug("run cmd '%s' in %s" % (cmd, os.getcwd() if destdir is None else destdir))
+ if logger:
+ logger.debug("run cmd '%s' in %s" % (cmd, os.getcwd() if destdir is None else destdir))
out = tempfile.TemporaryFile()
try:
subprocess.check_call(cmd, stdout=out, stderr=out, cwd=destdir, shell=True)
@@ -40,6 +41,7 @@ def runcmd(cmd, destdir=None, printerr=True, logger=None):
out.seek(0)
if printerr:
output = out.read()
+ output = output.decode('ascii').strip()
if logger:
logger.error("%s" % output)
else:
@@ -49,7 +51,9 @@ def runcmd(cmd, destdir=None, printerr=True, logger=None):
out.seek(0)
output = out.read()
- #logger.debug("output: %s" % output.rstrip() )
+ output = output.decode('ascii').strip()
+ if logger:
+ logger.debug("output: %s" % output.rstrip() )
return output
def setup_django():
--
1.9.1
More information about the yocto
mailing list