Beispiel #1
0
 def start(self):
     """
     Starts the process. If successful, show the button pressed.
     """
     # Call this to perform setup right before start
     self.onStart()
     # Now start...
     p = KProcess()
     cmd = self.command
     if isinstance(cmd, basestring):
         cmd = splitcommandline(cmd)
     if self.pty:
         # p.setUsePty does currently not work on Gentoo
         if hasattr(p, "setUsePty"):
             p.setUsePty(KProcess.Stdin, False)
         else:
             # Hack to let a process think it reads from a terminal
             cmd[0:0] = ["python", os.path.join(appdir, "runpty.py")]
     p.setExecutable(cmd[0])
     p.setArguments(cmd[1:])
     # Setup the signals
     if self.comm & KProcess.Stdin:
         self.pending = []
         p.connect(p, SIGNAL("wroteStdin(KProcess*)"), self.wroteStdin)
     if self.comm & KProcess.Stdout:
         p.connect(p, SIGNAL("receivedStdout(KProcess*, char*, int)"),
             self.receivedStdout)
     if self.comm & KProcess.Stderr:
         p.connect(p, SIGNAL("receivedStderr(KProcess*, char*, int)"),
             self.receivedStderr)
     p.connect(p, SIGNAL("processExited(KProcess*)"), self.processExited)
     if p.start(KProcess.NotifyOnExit, self.comm):
         self._p = p
         self.setDown(True)
         self.started()
     else:
         self._p = None
         self.failed()
Beispiel #2
0
 def start(self, runmode=KProcess.NotifyOnExit, comm=KProcess.AllOutput):
     res = KProcess.start(self, runmode, comm)
     if res:
         kprocess.__savedInstances.append(self)
         busy()
     return res