Changeset 56205

Show
Ignore:
Timestamp:
10/09/08 19:27:14 (6 weeks ago)
Author:
CJP
Message:

Fix some issues with killing processes, some minor updates to the test/demo.

Location:
wxPython/3rdParty/Editra
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • wxPython/3rdParty/Editra/src/eclib/outbuff.py

    r55987 r56205  
    190190        self.SetMarginWidth(1, 0) 
    191191 
     192        # To improve performance at cost of memory cache the document layout 
    192193        self.SetLayoutCache(wx.stc.STC_CACHE_DOCUMENT) 
    193194        self.SetUndoCollection(False) # Don't keep undo history 
     
    262263    def AppendUpdate(self, value): 
    263264        """Buffer output before adding to window. This method can safely be 
    264         called from non gui threads to add updates to the buffer. 
     265        called from non gui threads to add updates to the buffer, that will 
     266        be displayed durning the next idle period. 
    265267        @param value: update string to append to stack 
    266268 
     
    642644                if msg[0] in (109, errno.ESHUTDOWN): 
    643645                    return False 
    644  
    645646        else: 
    646647            # OSX and Unix nonblocking pipe read implementation 
     
    652653                fcntl.fcntl(self._proc.stdout, 
    653654                            fcntl.F_SETFL, 
    654                             flags| os.O_NONBLOCK) 
     655                            flags|os.O_NONBLOCK) 
    655656 
    656657            try: 
    657                 if not select.select([self._proc.stdout], [], [], 1)[0]: 
    658                     return True 
    659  
    660                 read = self._proc.stdout.readline() 
    661                 if read == '': 
     658                try: 
     659                    if not select.select([self._proc.stdout], [], [], 1)[0]: 
     660                        return True 
     661 
     662                    read = self._proc.stdout.readline() 
     663                    if read == '': 
     664                        return False 
     665                except IOError: 
    662666                    return False 
    663667            finally: 
     
    672676 
    673677        evt = OutputBufferEvent(edEVT_UPDATE_TEXT, self._parent.GetId(), result) 
    674         wx.CallAfter(wx.PostEvent, self._parent, evt) 
     678        wx.PostEvent(self._parent, evt) 
    675679        return True 
    676680 
     
    697701            # Try to kill the group 
    698702            try: 
    699                 pgid = os.getpgid(pid) 
    700                 os.killpg(pgid, signal.SIGKILL) 
     703                os.kill(pid, signal.SIGKILL) 
    701704            except OSError, msg: 
    702705                pass 
    703706 
    704707            # If still alive shoot it again 
    705             if self._proc.poll() != None: 
     708            if self._proc.poll() is not None: 
    706709                try: 
    707710                    os.kill(-pid, signal.SIGKILL) 
     
    711714            # Try and wait for it to cleanup 
    712715            try: 
    713                 os.waitpid(-pid, os.WNOHANG) 
     716                os.waitpid(pid, os.WNOHANG) 
    714717            except OSError, msg: 
    715718                pass 
     
    738741 
    739742        use_shell = not subprocess.mswindows 
    740         if use_shell: 
    741             preexec_fn = os.setsid 
    742         else: 
    743             preexec_fn = None 
    744  
    745         self._proc = subprocess.Popen(command.strip(), stdout=subprocess.PIPE, 
    746                                       preexec_fn=preexec_fn, 
    747                                       stderr=subprocess.STDOUT, shell=use_shell, 
    748                                       cwd=self._cwd, env=self._env) 
     743        self._proc = subprocess.Popen(command.strip(), 
     744                                      stdout=subprocess.PIPE, 
     745                                      stderr=subprocess.STDOUT, 
     746                                      shell=use_shell, 
     747                                      cwd=self._cwd, 
     748                                      env=self._env) 
    749749 
    750750        evt = OutputBufferEvent(edEVT_PROCESS_START, 
    751751                                self._parent.GetId(), 
    752752                                command.strip()) 
    753         wx.CallAfter(wx.PostEvent, self._parent, evt) 
     753        wx.PostEvent(self._parent, evt) 
    754754 
    755755        # Read from stdout while there is output from process 
     
    780780        # Pack the exit code as the events value 
    781781        evt = OutputBufferEvent(edEVT_PROCESS_EXIT, self._parent.GetId(), result) 
    782         wx.CallAfter(wx.PostEvent, self._parent, evt) 
     782        wx.PostEvent(self._parent, evt) 
    783783 
    784784    def SetArgs(self, args): 
  • wxPython/3rdParty/Editra/tests/controls/OutputBufferDemo.py

    r52085 r56205  
    105105            # Spawn a new ProcessThread 
    106106            combo = self.FindWindowById(ID_COMMAND) 
    107             self._buff.StartProcess('%s' % combo.GetValue()) 
     107            self._buff.StartProcess(u'%s' % combo.GetValue()) 
    108108            self.UpdateProcs() 
    109109        else: 
     
    287287        frame.SetSizer(sizer) 
    288288        frame.SetInitialSize() 
    289         frame.SetStatusText("OutputBuffer test") 
     289        frame.SetStatusText("OutputBufferDemo: wxPython %s, Python %s" % \ 
     290                            (wx.__version__, u".".join(str(x) for x in sys.version_info))) 
    290291        frame.Show() 
    291292        app.MainLoop()