def statusJob(jc): """A""" out, err = 'statusjob.out', 'statusjob.err' jobid_out = 'jobid' if os.path.exists(out): os.remove(out) if os.path.exists(err): os.remove(err) if not os.path.exists(jobid_out): print 'Cannot find jobid file: %s' % jobid command = 'edg-job-status -i %s 1>>%s 2>>%s' % (jobid_out, out, err) tklog.system(command, agtlog) job_id = '' job_status = '' job_ce = '' output = open(out, 'r') re_jobid = re.compile('^Status info for the Job :\s*([^\s]+)') re_status = re.compile('^Current Status:\s*(\w+)') re_ce = re.compile('^Destination:\s*([^\s]+)') for line in output.readlines(): if line.startswith('#'): continue line = line[:-1] mg1 = re_jobid.match(line) mg2 = re_status.match(line) mg3 = re_ce.match(line) if mg1: job_id = mg1.group(1) if mg2: job_status = mg2.group(1) if mg3: job_ce = mg3.group(1) output.close() bbb = os.path.basename(os.getcwd()) print 'Status of job %s : %s (CE=%s)' % (bbb, job_status, job_ce) return job_status
def update(self, tag): if self.isValidName(self.Name) and \ self.isValidName(self.TemplateName) and \ self.isValidName(self.HooksName): command = 'insert_in_tag.py -t "%s" %s %s %s' % \ (tag, self.TemplateName, self.Name, self.HooksName) tklog.system(command, aatlog) else: print 'Name: ', self.isValidName(self.Name) print 'TemplateName: ', self.isValidName(self.TemplateName) print 'HooksName: ', self.isValidName(self.HooksName)
def getJob(jc): """A""" jobid_out = 'jobid' jobid = os.path.basename(os.getcwd()) if not os.path.exists(jobid_out): print 'Cannot find jobid file: %s' % jobid if statusJob(jc) == 'Done': print 'Retrieving output of job %s' % jobid out, err = 'getjob.out', 'getjob.err' if os.path.exists(out): os.remove(out) if os.path.exists(err): os.remove(err) command = 'edg-job-get-output -i %s -dir . 1>>%s 2>>%s' % \ (jobid_out, out, err) (status, output) = tklog.system(command, agtlog) if status != 0: print 'Error while getting job output. Check output at %s' % out return output = open(out, 'r') check_it = False dir = '' for line in output.readlines(): line = line[:-1] if check_it: dir = line.strip() check_it = False break elif line.find('have been successfully retrieved and stored') >= 0: check_it = True continue if len(dir) > 0: print ' --> Job output stored in directory %s' % dir
def statusJob(jc): """A""" out, err = 'statusjob.out', 'statusjob.err' jobid_out = 'jobid' command = 'bjobs' (status, output) = tklog.system(command, altlog) sys.stdout.write(output) sys.stdout.flush()
def runJob(jc): """A""" out, err = 'runjob.out', 'runjob.err' jobid_out = 'jobid' jobid = jobID() print 'Submitting job %s' % jobid command = 'athena.py %s 1>>%s 2>>%s' % (jc.JobOptions.name(), out, err) (status, output) = tklog.system(command, altlog)
def runJob(jc): """A""" out, err = 'runjob.out', 'runjob.err' jobid_out = 'jobid' print 'Submitting job %s' % (os.path.basename(os.getcwd())) if os.path.exists(out): os.remove(out) if os.path.exists(err): os.remove(err) if os.path.exists(jobid_out): os.system('cat %s >> %s.sav' % (jobid_out, jobid_out)) os.remove(jobid_out) # print 'Submitting job %s to CE=%s' % (bbb) command = 'edg-job-submit --vo atlas -o %s %s 1>>%s 2>>%s' % \ (jobid_out, jc.JdlFile.name(), out, err) if jc.JobType.name(): if os.path.exists(jc.RunScript.name()): os.chmod(jc.RunScript.name(), 0744) command = '%s 1>>%s 2>>%s &' % (jc.RunScript.name(), out, err) else: return (status, output) = tklog.system(command, agtlog) if status != 0: print '*** Error while submitting job %s. Check the output %s/%s' %\ (os.path.basename(os.getcwd()), os.getcwd(), out)