def _launch_pcgamess(self): """ Run PC GAMESS (Windows only). PC GAMESS creates 2 output files: - the DAT file, called "PUNCH", is written to the directory from which PC GAMESS is started. This is why we chdir to the Gamess temp directory before we run PC GAMESS. - the OUT file (aka the log file), which we name jigname.out. Returns: 0 = Success 1 = Cancelled 2 = Failed """ oldir = os.getcwd() # Save current directory jobDir = os.path.dirname(self.job_batfile) os.chdir(jobDir) # Change directory to the GAMESS temp directory. ## print "Current directory is: ", jobDir DATfile = os.path.join(jobDir, "PUNCH") if os.path.exists(DATfile): # Remove any previous DAT (PUNCH) file. print "run_pcgamess: Removing DAT file: ", DATfile os.remove(DATfile) # Hours wasted testing this undocumented tripe. Here's the deal: When using spawnv # on Windows, any args that might have spaces must be delimited by double quotes. # Mark 050530. #program = "\"" + self.job_batfile + "\"" #args = [program, ] # Here's the infuriating part. The 2nd arg to spawnv cannot have double quotes, but the # first arg in args (the program name) must have the double quotes if there is a space in # self.gms_program. #print "program = ", program #print "Spawnv args are %r" % (args,) # this %r remains (see above) #os.spawnv(os.P_WAIT, self.job_batfile, args) arg_list = ['-i', self.job_inputfile, '-o', self.job_outputfile] args = QStringList() for s in arg_list: args.append(str(s)) process = QProcess() process.start(self.server.program, args) # Blocks for n millisconds until the process has started and started() # signal is emitted. Returns true if the process was started successfullly. if not process.waitForStarted(2000): print "The process can't be started." return 2 progressDialog = self.showProgress() progressDialog.show() i = 55 pInc = True while process.state() == QProcess.Running: env.call_qApp_processEvents() #bruce 050908 replaced qApp.processEvents() if progressDialog.wasCanceled(): process.kill() os.chdir(oldir) return 1 # Job cancelled. progressDialog.setValue(i) if pInc: if i < 75: i += 1 else: pInc = False else: if i > 55: i -= 1 else: pInc = True # Do sth here time.sleep(0.05) if not process.state() == QProcess.Running: break progressDialog.setValue(100) progressDialog.accept() os.chdir(oldir) self.gamessJig.outputfile = self.job_outputfile return 0 # Success
def _launch_pcgamess(self): """ Run PC GAMESS (Windows only). PC GAMESS creates 2 output files: - the DAT file, called "PUNCH", is written to the directory from which PC GAMESS is started. This is why we chdir to the Gamess temp directory before we run PC GAMESS. - the OUT file (aka the log file), which we name jigname.out. Returns: 0 = Success 1 = Cancelled 2 = Failed """ oldir = os.getcwd() # Save current directory jobDir = os.path.dirname(self.job_batfile) os.chdir(jobDir) # Change directory to the GAMESS temp directory. ## print "Current directory is: ", jobDir DATfile = os.path.join(jobDir, "PUNCH") if os.path.exists(DATfile): # Remove any previous DAT (PUNCH) file. print "run_pcgamess: Removing DAT file: ", DATfile os.remove(DATfile) # Hours wasted testing this undocumented tripe. Here's the deal: When using spawnv # on Windows, any args that might have spaces must be delimited by double quotes. # Mark 050530. #program = "\"" + self.job_batfile + "\"" #args = [program, ] # Here's the infuriating part. The 2nd arg to spawnv cannot have double quotes, but the # first arg in args (the program name) must have the double quotes if there is a space in # self.gms_program. #print "program = ", program #print "Spawnv args are %r" % (args,) # this %r remains (see above) #os.spawnv(os.P_WAIT, self.job_batfile, args) arg_list = ['-i', self.job_inputfile, '-o', self.job_outputfile] args = QStringList() for s in arg_list: args.append(str(s)) process = QProcess() process.start(self.server.program, args) # Blocks for n millisconds until the process has started and started() # signal is emitted. Returns true if the process was started successfullly. if not process.waitForStarted(2000): print "The process can't be started." return 2 progressDialog = self.showProgress() progressDialog.show() i = 55 pInc = True while process.state() == QProcess.Running: env.call_qApp_processEvents( ) #bruce 050908 replaced qApp.processEvents() if progressDialog.wasCanceled(): process.kill() os.chdir(oldir) return 1 # Job cancelled. progressDialog.setValue(i) if pInc: if i < 75: i += 1 else: pInc = False else: if i > 55: i -= 1 else: pInc = True # Do sth here time.sleep(0.05) if not process.state() == QProcess.Running: break progressDialog.setValue(100) progressDialog.accept() os.chdir(oldir) self.gamessJig.outputfile = self.job_outputfile return 0 # Success