示例#1
0
 def run_command(self, program, args):
     if debug_run():
         print "will run this command:", program, args
     from PyQt4.Qt import QStringList, QProcess, QObject, SIGNAL, QDir
     # modified from runSim.py
     arguments = QStringList()
     if sys.platform == 'win32':
         program = "\"%s\"" % program # Double quotes needed by Windows. ###@@@ test this
     ### try it with blanks in output file name and in program name, once it works ###@@@
     for arg in [program] + args:
         if arg:
             arguments.append(arg)
     self.simProcess = simProcess = QProcess()
     simProcess.setArguments(arguments)
     simProcess.setWorkingDirectory(QDir(self.working_directory)) # in case it writes random files
     if 1:
         # report stdout/stderr
         def blabout():
             print "stdout:", simProcess.readStdout()
             ##e should also mention its existence in history, but don't copy it all there in case a lot
         def blaberr():
             text = str(simProcess.readStderr()) # str since it's QString (i hope it can't be unicode)
             print "stderr:", text
             env.history.message(redmsg("%s stderr: " % self.plugin_name + quote_html(text)))
             # examples from CoNTub/bin/HJ:
             # stderr: BAD INPUT
             # stderr: Error: Indices of both tubes coincide
         QObject.connect(simProcess, SIGNAL("readyReadStdout()"), blabout)
         QObject.connect(simProcess, SIGNAL("readyReadStderr()"), blaberr)
     started = simProcess.start() ###k what is this code? i forget if true means ok or error
     if debug_run():
         print "qprocess started:",started
     while 1:
         ###e need to make it abortable! from which abort button? ideally, one on the dialog; maybe cancel button??
         # on exception: simProcess.kill()
         if simProcess.isRunning():
             if debug_run():
                 print "still running"
                 time.sleep(1)
             else:
                 time.sleep(0.1)
         else:
             break
     if debug_run():
         print "process done i guess: normalExit = %r, (if normal) exitStatus = %r" % \
               (simProcess.normalExit(), simProcess.exitStatus())
     if 1:
         QObject.disconnect(simProcess, SIGNAL("readyReadStdout()"), blabout)
         QObject.disconnect(simProcess, SIGNAL("readyReadStderr()"), blaberr)
     if simProcess.normalExit():
         return simProcess.exitStatus()
     else:
         return -1
示例#2
0
def ubsubscribe_nodelist(callback):
    QObject.disconnect(nodelist, PYSIGNAL("loaded()"), callback)
示例#3
0
 def unsubscribe_state(self, callback):
     _dprint(4, "disconnecting state of node ", self.name, " from ",
             callback)
     QObject.disconnect(self, PYSIGNAL("state()"), callback)
示例#4
0
def ubsubscribe_nodelist (callback):
  QObject.disconnect(nodelist,PYSIGNAL("loaded()"),callback);
示例#5
0
 def unsubscribe_state (self,callback):
   _dprint(4,"disconnecting state of node ",self.name," from ",callback);
   QObject.disconnect(self,PYSIGNAL("state()"),callback);