Allow specification of command line arguments encoding in ProcessLogger
authorEdouard Tisserant
Tue, 10 Jun 2014 11:40:50 +0200
changeset 1415 c411fc7246eb
parent 1414 8a3998d10b81
child 1416 d4222bad4841
Allow specification of command line arguments encoding in ProcessLogger
util/ProcessLogger.py
--- a/util/ProcessLogger.py	Wed Jun 04 13:18:23 2014 +0200
+++ b/util/ProcessLogger.py	Tue Jun 10 11:40:50 2014 +0200
@@ -71,7 +71,8 @@
     def __init__(self, logger, Command, finish_callback = None,
                  no_stdout = False, no_stderr = False, no_gui = True,
                  timeout = None, outlimit = None, errlimit = None,
-                 endlog = None, keyword = None, kill_it = False, cwd = None):
+                 endlog = None, keyword = None, kill_it = False, cwd = None,
+                 encoding = None):
         self.logger = logger
         if not isinstance(Command, list):
             self.Command_str = Command
@@ -87,8 +88,12 @@
             self.Command = Command
             self.Command_str = subprocess.list2cmdline(self.Command)
 
-        self.Command = map(lambda x: x.encode(sys.getfilesystemencoding()),
-                           self.Command)
+        fsencoding = sys.getfilesystemencoding()
+
+        if encoding is None:
+            encoding = fsencoding
+        self.Command = [self.Command[0].encode(fsencoding)]+map(
+            lambda x: x.encode(encoding), self.Command[1:])
 
         self.finish_callback = finish_callback
         self.no_stdout = no_stdout