wxPopen.py
changeset 149 fc7fe0de9143
parent 130 9af34a1d33b7
child 151 43614ea83d2a
equal deleted inserted replaced
148:8be272b35525 149:fc7fe0de9143
    43         self.callback = callback
    43         self.callback = callback
    44         self.endcallback = endcallback
    44         self.endcallback = endcallback
    45         self.fd = fd
    45         self.fd = fd
    46 
    46 
    47     def run(self):
    47     def run(self):
    48         outeof = False
    48         self.retval = None
    49         self.retval = self.Proc.poll()
    49         while self.retval is None and not self.killed :
    50         while not self.retval and not self.killed and not outeof:   
    50             self.retval = self.Proc.poll()
    51             outchunk = self.fd.readline()
    51             outchunk = self.fd.readline()
    52             if outchunk == '': outeof = True
    52             if outchunk == '':
       
    53                 break
    53             if self.callback :
    54             if self.callback :
    54                 wx.CallAfter(self.callback,outchunk)
    55                 wx.CallAfter(self.callback,outchunk)
    55             self.retval=self.Proc.poll()
       
    56         if self.endcallback:
    56         if self.endcallback:
    57             try:
    57             try:
    58             	err = self.Proc.wait()
    58             	err = self.Proc.wait()
    59             except:
    59             except:
    60             	pass
    60                 err = self.retval
    61             self.finished = True
    61             self.finished = True
    62             wx.CallAfter(self.endcallback, self.Proc.pid, self.retval)
    62             wx.CallAfter(self.endcallback, self.Proc.pid, err)
    63 
    63 
    64 class ProcessLogger:
    64 class ProcessLogger:
    65     def __init__(self, logger, Command, finish_callback=None, no_stdout=False, no_stderr=False, no_gui=True):
    65     def __init__(self, logger, Command, finish_callback=None, no_stdout=False, no_stderr=False, no_gui=True):
    66         self.logger = logger
    66         self.logger = logger
    67         self.Command = Command
    67         self.Command = Command
    87             popenargs["startupinfo"] = self.startupinfo
    87             popenargs["startupinfo"] = self.startupinfo
    88         elif wx.Platform == '__WXGTK__':
    88         elif wx.Platform == '__WXGTK__':
    89             popenargs["shell"] = True
    89             popenargs["shell"] = True
    90         
    90         
    91         self.Proc = subprocess.Popen( self.Command, **popenargs )
    91         self.Proc = subprocess.Popen( self.Command, **popenargs )
    92 
       
    93 
    92 
    94         self.outt = outputThread(
    93         self.outt = outputThread(
    95                       self.Proc,
    94                       self.Proc,
    96                       self.Proc.stdout,
    95                       self.Proc.stdout,
    97                       self.output,
    96                       self.output,