]> code.ossystems Code Review - openembedded-core.git/commitdiff
wic: decode output of subprocess.communicate
authorEd Bartosh <ed.bartosh@linux.intel.com>
Wed, 4 May 2016 13:06:25 +0000 (16:06 +0300)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 14 May 2016 06:26:42 +0000 (07:26 +0100)
stdeout and stderr content returned by communicate API has different
types in Python 3(bytes) and Python 2(string). Decoding it to 'utf-8'
makes it unicode on both pythons.

Decoded stdout and stderr output to utf-8 to make the code
working under both Python 2 and Python 3.

Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
scripts/lib/wic/utils/runner.py

index 737751bd73dff6bfa7c40430f172fb727a08a28e..db536ba5882839fa1da19a0b2b14ccdd177473b9 100644 (file)
@@ -65,8 +65,8 @@ def runtool(cmdln_or_args, catch=1):
         process = subprocess.Popen(cmdln_or_args, stdout=sout,
                                    stderr=serr, shell=shell)
         (sout, serr) = process.communicate()
-        # combine stdout and stderr, filter None out
-        out = ''.join(filter(None, [sout, serr]))
+        # combine stdout and stderr, filter None out and decode
+        out = ''.join([out.decode('utf-8') for out in [sout, serr] if out])
     except OSError as err:
         if err.errno == 2:
             # [Errno 2] No such file or directory