liveusb/creator.py

Luke Macken lmacken at fedoraproject.org
Tue Dec 8 00:26:34 UTC 2009


 liveusb/creator.py |    6 ++++++
 1 file changed, 6 insertions(+)

New commits:
commit e30777a322bfcad3ceb16fc4b293e4a8e003da73
Author: Luke Macken <lmacken at redhat.com>
Date:   Mon Dec 7 19:26:08 2009 -0500

    Ensure our command and subprocess output are byte strings

diff --git a/liveusb/creator.py b/liveusb/creator.py
index 2b7a403..bd0f200 100755
--- a/liveusb/creator.py
+++ b/liveusb/creator.py
@@ -178,12 +178,18 @@ class LiveUSBCreator(object):
         @param kwargs: Extra arguments to pass to subprocess.Popen
         """
         self.log.debug(cmd)
+        if isinstance(cmd, unicode):
+            cmd = cmd.encode('utf-8', 'replace')
         self.output.write(cmd)
         proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE, stdin=subprocess.PIPE,
                                 shell=True, **kwargs)
         self.pids.append(proc.pid)
         out, err = proc.communicate()
+        if isinstance(out, unicode):
+            out = out.encode('utf-8', 'replace')
+        if isinstance(err, unicode):
+            err = err.encode('utf-8', 'replace')
         self.output.write(out + '\n' + err + '\n')
         if proc.returncode:
             self.write_log()




More information about the liveusb-creator mailing list