[oe-commits] [openembedded-core] 14/21: wic: decode output of subprocess.communicate

git at git.openembedded.org git at git.openembedded.org
Fri May 13 17:10:51 UTC 2016


rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit c62115eebe82d5b0b619855e251fbc76318e7d27
Author: Ed Bartosh <ed.bartosh at linux.intel.com>
AuthorDate: Wed May 4 16:06:25 2016 +0300

    wic: decode output of subprocess.communicate
    
    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 at linux.intel.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 scripts/lib/wic/utils/runner.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/lib/wic/utils/runner.py b/scripts/lib/wic/utils/runner.py
index 737751b..db536ba 100644
--- a/scripts/lib/wic/utils/runner.py
+++ b/scripts/lib/wic/utils/runner.py
@@ -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

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list