67 self.endcallback(self.Proc.pid, err) |
67 self.endcallback(self.Proc.pid, err) |
68 |
68 |
69 class ProcessLogger: |
69 class ProcessLogger: |
70 def __init__(self, logger, Command, finish_callback=None, no_stdout=False, no_stderr=False, no_gui=True): |
70 def __init__(self, logger, Command, finish_callback=None, no_stdout=False, no_stderr=False, no_gui=True): |
71 self.logger = logger |
71 self.logger = logger |
72 self.Command_str = Command |
72 if not isinstance(Command, list): |
73 self.Command = [] |
73 self.Command_str = Command |
74 for i,word in enumerate(Command.replace("'",'"').split('"')): |
74 self.Command = [] |
75 if i % 2 == 0: |
75 for i,word in enumerate(Command.replace("'",'"').split('"')): |
76 word = word.strip() |
76 if i % 2 == 0: |
77 if len(word) > 0: |
77 word = word.strip() |
78 self.Command.extend(word.split()) |
78 if len(word) > 0: |
79 else: |
79 self.Command.extend(word.split()) |
80 self.Command.append(word) |
80 else: |
81 |
81 self.Command.append(word) |
|
82 else: |
|
83 self.Command = Command |
|
84 self.Command_str = subprocess.list2cmdline(self.Command) |
|
85 |
82 self.finish_callback = finish_callback |
86 self.finish_callback = finish_callback |
83 self.no_stdout = no_stdout |
87 self.no_stdout = no_stdout |
84 self.no_stderr = no_stderr |
88 self.no_stderr = no_stderr |
85 self.startupinfo = None |
89 self.startupinfo = None |
86 self.errlen = 0 |
90 self.errlen = 0 |
93 popenargs= { |
97 popenargs= { |
94 "cwd":os.getcwd(), |
98 "cwd":os.getcwd(), |
95 "stdin":subprocess.PIPE, |
99 "stdin":subprocess.PIPE, |
96 "stdout":subprocess.PIPE, |
100 "stdout":subprocess.PIPE, |
97 "stderr":subprocess.PIPE} |
101 "stderr":subprocess.PIPE} |
|
102 |
98 if no_gui == True and wx.Platform == '__WXMSW__': |
103 if no_gui == True and wx.Platform == '__WXMSW__': |
99 self.startupinfo = subprocess.STARTUPINFO() |
104 self.startupinfo = subprocess.STARTUPINFO() |
100 self.startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW |
105 self.startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW |
101 popenargs["startupinfo"] = self.startupinfo |
106 popenargs["startupinfo"] = self.startupinfo |
102 elif wx.Platform == '__WXGTK__': |
107 elif wx.Platform == '__WXGTK__': |