69 |
69 |
70 class ProcessLogger: |
70 class ProcessLogger: |
71 def __init__(self, logger, Command, finish_callback = None, |
71 def __init__(self, logger, Command, finish_callback = None, |
72 no_stdout = False, no_stderr = False, no_gui = True, |
72 no_stdout = False, no_stderr = False, no_gui = True, |
73 timeout = None, outlimit = None, errlimit = None, |
73 timeout = None, outlimit = None, errlimit = None, |
74 endlog = None, keyword = None, kill_it = False, cwd = None): |
74 endlog = None, keyword = None, kill_it = False, cwd = None, |
|
75 encoding = None): |
75 self.logger = logger |
76 self.logger = logger |
76 if not isinstance(Command, list): |
77 if not isinstance(Command, list): |
77 self.Command_str = Command |
78 self.Command_str = Command |
78 self.Command = [] |
79 self.Command = [] |
79 for i,word in enumerate(Command.replace("'",'"').split('"')): |
80 for i,word in enumerate(Command.replace("'",'"').split('"')): |
85 self.Command.append(word) |
86 self.Command.append(word) |
86 else: |
87 else: |
87 self.Command = Command |
88 self.Command = Command |
88 self.Command_str = subprocess.list2cmdline(self.Command) |
89 self.Command_str = subprocess.list2cmdline(self.Command) |
89 |
90 |
90 self.Command = map(lambda x: x.encode(sys.getfilesystemencoding()), |
91 fsencoding = sys.getfilesystemencoding() |
91 self.Command) |
92 |
|
93 if encoding is None: |
|
94 encoding = fsencoding |
|
95 self.Command = [self.Command[0].encode(fsencoding)]+map( |
|
96 lambda x: x.encode(encoding), self.Command[1:]) |
92 |
97 |
93 self.finish_callback = finish_callback |
98 self.finish_callback = finish_callback |
94 self.no_stdout = no_stdout |
99 self.no_stdout = no_stdout |
95 self.no_stderr = no_stderr |
100 self.no_stderr = no_stderr |
96 self.startupinfo = None |
101 self.startupinfo = None |