16 if not os.path.exists(path+
"/jobExitCode.txt"):
17 print path+
"/jobExitCode.txt",
"missing - skipping this nightly"
19 f =
open(path+
"/jobExitCode.txt")
20 print "Checking job status..."
21 print "Found "+path+
"/jobExitCode.txt"
27 if "<jobSuccess>True</jobSuccess>" in line:
30 elif "<jobSuccess>False</jobSuccess>" in line:
33 if file_status:
print "Job succeeded in this nightly."
35 print "Job failed in this nightly."
39 if os.path.exists(path+
"/rttjobinfo.xml"):
41 f =
open(path+
"/rttjobinfo.xml")
44 m=re.search(
'<timeStamp>([0-9]*)</timeStamp>',l)
49 yes=dt.date.fromtimestamp(ts)
54 print 'WARNING results found in '+path+
' are more than a week old'
56 return file_status,days
60 print "---------------------------------------------------------------------------------------"
61 pathlist=path.split(
'/')
64 for i,a
in enumerate(pathsplit):
67 release_list=a.split(
'_')
68 todays_release=pathlist[pos_index]
72 release_tag=release_list[0]+
"_"+
str(i)
74 pathlist[pos_index]=release_tag
75 path_refill=
"/".
join(pathlist)
77 print "Checking for results for "+release_tag+
"..."
80 print "==> Nightly: "+release_tag+
" Age: "+
str(days_tmp)+
" days"
81 if days_tmp>=0
and days_tmp<recent_days:
85 print "==> Nightly: "+release_tag+
" Age: N/A"
86 print "---------------------------------------------------------------------------------------"
88 print "=====> Could not find another release to compare to. Returning today's nightly ("+todays_release+
") as the reference."
90 good_rel_refease=
"rel_"+
str(recent_index)
91 print "=====> "+good_rel_refease+
" is the most recent nightly to use as reference."
92 return good_rel_refease
95 def eoscp(package,filename,jobname,nightly,tag,store_tag,release):
98 if os.environ.has_key(
'LS_SUBCWD'):
99 current=os.environ[
'LS_SUBCWD']
101 argv=current.split(
'/')
115 postfix=
"x86_64-slc6-gcc62-opt/Athena/"+package
119 pathlist=[
"prod",
"batch"]
121 for path
in pathlist:
122 prefix=
"root://eosatlas.cern.ch//eos/atlas/atlascerngroupdisk/proj-sit/rtt/"+path+
"/rtt"
128 path=prefix+
'/'+release+
'/'+middle+
'/'+postfix+
'/'+jobname+
'/'+filename
129 print "Path to check on eos: "+path
131 command_cp=
"xrdcp %s %s.%s.root"%(path,tag,store_tag)
133 command_cp=
"xrdcp %s %s.%s"%(path,tag,filename)
135 status=os.system(command_cp)
136 if status==0:
return status
140 if __name__ ==
"__main__":
141 print '------------------usage-----------------'
142 print 'sim_reg_test_fastchain.py [ref package] [ref rel] [ref job name] [ref filename] [mon package] [mon rel] [mon job name] [mon filename]'
143 print 'packages supported are ISF_Validation and FastChainPileup'
144 print 'to use current release, put "current" as a release argument'
145 print 'if job fails for today`s ref/mon, the latest succeeded job will be taken'
146 print '----------------------------------------'
148 print 'Got input arguments:'
150 print 'package: ', sys.argv[1]
151 print 'release: ', sys.argv[2]
152 print 'job: ', sys.argv[3]
153 print 'filename: ', sys.argv[4]
155 print 'package: ', sys.argv[5]
156 print 'release: ', sys.argv[6]
157 print 'job: ', sys.argv[7]
158 print 'filename: ', sys.argv[8]
159 if sys.argv[1]!=
'ISF_Validation' and sys.argv[1]!=
'FastChainPileup' :
160 print 'ERROR: unsupported reference package.'
161 if sys.argv[5]!=
'ISF_Validation' and sys.argv[5]!=
'FastChainPileup' :
162 print 'ERROR: unsupported monitored package.'
165 prepath=
'/afs/cern.ch/atlas/project/RTT/prod/Results/rtt/rel_0/'
167 postpath=
'/build/x86_64-slc6-gcc62-opt/Athena/'
169 if sys.argv[6] ==
'current' or sys.argv[2] ==
'current' :
171 if os.environ.has_key(
'LS_SUBCWD'):
172 curdir= os.environ[
'LS_SUBCWD']
176 folders=curdir.split(
'/')
178 for idx, folder
in enumerate(folders):
179 if 'rel_' in folder :
181 currel = folders[idx+1]
183 print 'ERROR: Could not find current release in the path after /rel_*/'
184 if currel ==
'NOREL' :
185 print 'ERROR: Could not find current release in the path. Setting release to "NOREL" and going to crash.'
188 if sys.argv[6] ==
'current' :
190 pwdmon=prepath + relmon + postpath
193 prepath=
'/afs/cern.ch/atlas/project/RTT/prod/Results/rtt/rel_0/'
194 postpath=
'/build/x86_64-slc6-gcc62-opt/Athena/'
196 if sys.argv[2] ==
'current' :
198 pwdref=prepath + relref + postpath
200 argvref=pwdref.split(
'/')
202 argvref.append(sys.argv[1])
203 argvref.append(sys.argv[3])
204 print 'argvref ',argvref
205 corr_path_ref=
'/'.
join(argvref)
206 print 'reference path:', corr_path_ref
208 print '###### Get the most recent successful reference job ######'
216 argvmon=pwdmon.split(
'/')
218 argvmon.append(sys.argv[5])
219 argvmon.append(sys.argv[7])
220 print 'argvmon ',argvmon
221 corr_path_mon=
'/'.
join(argvmon)
222 print 'monitored path:', corr_path_mon
223 print '###### Get the most recent successful monitored job ######'
227 for i,a
in enumerate(argvref):
228 if a.find(
"rel_")>=0 :
232 for i,a
in enumerate(argvmon):
233 if a.find(
"rel_")>=0 :
236 argvmon[posmon]=good_rel_mon
239 argvref[posref]=good_rel_ref
242 print "Releases to compare: "+good_rel_ref+
", "+good_rel_mon
251 compfilesref=[
'ISFBroker.root']
252 compfilesmon=[
'ISFBroker.root']
263 compfilesref.append(sys.argv[4])
264 compfilesmon.append(sys.argv[8])
265 print 'compfilesref:',compfilesref
266 print 'compfilesref:',compfilesmon
267 file_list_ref=compfilesref[:]
269 file_list_val=compfilesmon[:]
271 print "Confirming monitored job status..."
274 if file_status_val==
True:
277 for f
in os.listdir(monPath):
278 if f.endswith(file_name)
and f !=
'yesterday.root' and f!=
'today.root':
280 name,suffix=f.split(
'.',1)
281 if f
in compfilesmon:
284 elif len(compfilesmon)>=2:
287 cmd =
'cp'+
' '+monPath+
'/'+f+
' '+
'today.'+store_tag+
".root"
289 cmd =
'cp'+
' '+monPath+
'/'+f+
' '+
'today.'+suffix
294 if f
in file_list_val:
295 file_list_val.remove(f)
297 if 'ISFBroker.root' in file_list_val:
298 file_list_val.remove(
'ISFBroker.root')
299 if len(file_list_val)!=0:
300 print "The following files were not found in the output directory of today's job: "+
str(file_list_val)+
", will try to copy them from EOS instead."
301 for val_f
in file_list_val:
302 if eoscp(sys.argv[5],val_f,sys.argv[7],sys.argv[6],
"today",store_tag,good_rel_mon)!=0 :
303 print "File does not exist in EOS."
305 file_list_val.remove(val_f)
308 file_status_ref=
False
309 file_list_ref_orig = file_list_ref
311 print "Confirming reference job status..."
313 if file_status_ref==
True:
316 for f
in os.listdir(refPath):
317 if f.endswith(file_name)
and f !=
'yesterday.root' and f!=
'today.root':
320 name,suffix=f.split(
'.',1)
322 if f
in compfilesref:
325 elif len(compfilesref)>=2:
328 cmd =
'cp'+
' '+refPath+
'/'+f+
' '+
'yesterday.'+store_tag+
'.root'
330 cmd =
'cp'+
' '+refPath+
'/'+f+
' '+
'yesterday.'+suffix
335 if f
in file_list_ref:
336 file_list_ref.remove(f)
338 if 'ISFBroker.root' in file_list_ref:
339 file_list_ref.remove(
'ISFBroker.root')
340 if len(file_list_ref)!=0:
341 print "The following files were not found in the output directory of "+good_rel_ref+
"'s job: "+
str(file_list_ref)+
", will try to copy them from EOS instead."
342 for ref_f
in file_list_ref :
343 if eoscp(sys.argv[1],ref_f,sys.argv[3],sys.argv[2],
"yesterday",store_tag,good_rel_ref)!=0:
344 print "File does not exist in EOS."
346 file_list_ref.remove(ref_f)
348 if len(file_list_ref)==0:
352 print "Could not find a full set of files for "+good_rel_ref+
", so removing any we did find."
353 if(len(file_list_ref)+1) < len(file_list_ref_orig): os.system(
'rm yesterday.*')
354 file_list_ref = file_list_ref_orig
355 file_status_ref=
False
356 previous_rel = good_rel_ref
357 if good_rel_ref ==
'rel_0':
358 good_rel_ref =
'rel_6'
360 good_rel_ref =
'rel_%d' % (
int(good_rel_ref.split(
'_')[1])-1)
362 argvref[pos]=good_rel_ref
363 refPath=
'/'.
join(argvref)
364 print "As we failed to find all required files in "+previous_rel+
", trying again with "+good_rel_ref
368 if not file_status_ref==
True:
369 print(
"Failed to find a usable reference nightly!")
372 print "leaving with code 0"
374 elif file_status_val==
False:
375 print "Failed to find expected files in the path for today's nightly!"
377 except (OSError,IOError):
378 print "No running in this release!"