diff --git a/parametricJob.py b/parametricJob.py index 616d0badbff4a049eb1dd7186c145871912d364a..a5c766b17be51e154dc27e48a14c12c9df09bfad 100644 --- a/parametricJob.py +++ b/parametricJob.py @@ -4,7 +4,7 @@ #from future import standard_library #standard_library.install_aliases() import sys, os, os.path, shutil, socket, platform, glob, fnmatch -import datetime, tarfile, subprocess, string +import datetime, tarfile, subprocess, string, re from prmClasses import * # -- Base Class ---------------------------------------------------------------- @@ -35,7 +35,6 @@ class ParametricJob(PRMSet): return niceCmd def getMailData(self): - import re fromAddr = "%s@%s" % (os.path.basename(sys.argv[0]), socket.gethostbyaddr(socket.gethostname())[0]) toAddr = self.pars['MAIL_ADDR'].val if re.match('(.+)@(.+)',toAddr): @@ -166,7 +165,6 @@ class ParametricJob(PRMSet): return cfgfile def hasSysCmd(self, cmd): - import subprocess status, result = subprocess.getstatusoutput("which %s" % cmd) return status==0 @@ -269,7 +267,6 @@ class ParametricJob(PRMSet): # get guess profile cfgfile = self.guessProfile() cfgFileName, cfgFileExtension = os.path.splitext(self.cfgfile) - import re m = re.compile(cfgFileName+'([0-9]+)\\'+cfgFileExtension) #print (cfgFileName+'([0-9]+)\\'+cfgFileExtension) launchId = 0 @@ -312,14 +309,12 @@ class ParametricJob(PRMSet): #shcmd="at now + 1 minutes -f %s" % (scriptname) #shcmd="at now %s" % scriptname print("shcmd = ", shcmd) - import subprocess status, result = subprocess.getstatusoutput(shcmd) if status!=0: print("Job submission FAILED!") else: print("Submission SUCCESSFUL!") #print "result = ", result - import re m = re.search('job ([0-9]+)',result) batchId = m.group(1) #print m.group @@ -402,14 +397,12 @@ class ParametricJob(PRMSet): # send to sge print("sending job '%s' to SGE" % jobname) shcmd="qsub ./%s" % scriptname - import subprocess status, result = subprocess.getstatusoutput(shcmd) print(result) if status!=0: print("Job submission FAILED!") else: print("Submission SUCCESSFUL!") - import re m = re.compile('Your job ([0-9]+)').match(result) sgeId = m.group(1) if m: @@ -498,14 +491,12 @@ class ParametricJob(PRMSet): # send to slurm print("sending job '%s' to Slurm" % jobname) shcmd="sbatch ./%s" % scriptname - import subprocess status, result = subprocess.getstatusoutput(shcmd) print(result) if status!=0: print("Job submission FAILED!") else: print("Submission SUCCESSFUL!") - import re m = re.compile('Submitted batch job ([0-9]+)').match(result) slurmId = m.group(1) if m: @@ -628,7 +619,6 @@ class ParametricJob(PRMSet): # send to PBS print('sending job "%s" to PBS' % jobname) shcmd='qsub ./%s' % scriptname - import subprocess status, result = subprocess.getstatusoutput(shcmd) print('command status = ', status) print('command result = ', result) @@ -644,23 +634,6 @@ class ParametricJob(PRMSet): self.PBSCancelScript(PbsId) print("\tuse ' qstat -f %s ' to check the status of the PBS scheduling queue of your job" % PbsId) print("\tuse ' qdel %s ' to kill your job" % PbsId) - ''' - #import re - #m = re.compile('waiting for job ([0-9]+) to start').match(result) - #result : 3067709.frontal2 - #m = re.compile('([0-9]+)\.(.+)').match(result) - #print "m = ", m - #PbsId = m.group(1) - if m: - cfgFileName, cfgFileExtension = os.path.splitext(self.cfgfile) - os.system("cp %s %s%s%s"%(self.cfgfile, cfgFileName, PbsId, cfgFileExtension)) - self.PBSCancelScript(PbsId) - print "\tuse ' qstat -f %s ' to check the status of the PBS scheduling queue of your job" % PbsId - #print "\tuse ' sprio -l -j %s ' to check the factor priority of your job" % PbsId - #print "\tuse ' sstat -a --format=JobID,NTasks,MaxRSS,MaxVMSize -j %s ' to get information about your running job (adapt format to your needs)" % PbsId - print "\tuse ' qdel %s ' to kill your job" % PbsId - #print "\tuse ' sacct --format=JobID,NTasks,NCPUS,CPUTime,Elapsed,MaxRSS,MaxVMSize -j %s ' to get information about your finished job (adapt format to your needs)" % PbsId - ''' # to avoid closing the gui if not (re.match(r'(.+)Gui.pyw', sys.argv[0])): sys.exit()