5 from xml.dom.minidom
import parse
12 if not rel.startswith(
"rel_"):
14 arch = os.environ[
'CMTCONFIG']
15 if build.startswith(
"17.")
or build.startswith(
"18."):
16 arch =
"i686-slc5-gcc43-opt"
17 return "/afs/cern.ch/atlas/project/RTT/prod/Results/rtt/"+rel+
"/"+build+
"/build/"+arch+
"/Athena/Tier0ChainTests/"
33 def __init__(self, rDir, vDir, checkAge = False):
43 fileTime = os.stat(path)[8]
46 age = time() - fileTime
49 print (
"WARNING! File %s is more than %d day(s) old" % (path,
int(age/86400.)))
58 if os.path.isfile(logpath)
and f.endswith(
"_log")
and not f.endswith(
"_script_log"):
64 print (
"ERROR: Duplicate directory name",name)
74 newSplit=file.split(
"/")
75 newStream=newSplit[-3]
78 oldSplit=old.split(
"/")
79 if oldSplit[-1]==newFile
and oldSplit[-3]==newStream:
87 start = s.index( first ) + len( first )
88 end = s.index( last, start )
94 validationStartLine =
"INFO Validating output files"
97 lf =
open(tci.logfile,
"r")
102 foundFileValidationStart =
False
103 nextLineHasEventCount =
False
104 lastOutputFileName =
""
107 if not foundFileValidationStart:
108 if validationStartLine
in l:
109 foundFileValidationStart =
True
110 elif "Testing event count..." in l:
111 format = self.
findBetween(l,
"INFO",
"Testing event count...").strip()
112 tci.outputDict[format] = -1
113 nextLineHasEventCount =
True
114 lastOutputFileName = format
115 elif nextLineHasEventCount:
116 tci.outputDict[lastOutputFileName] =
int(self.
findBetween(l,
"Event counting test passed (",
" events)."))
117 nextLineHasEventCount =
False
122 return tci.outputDict
125 print (
"Input directory:",self.
_rDir)
126 print (
"Searching for TCT sub-directories")
128 print (
"Found ",len(self.
_commonDirs),
"directories")
133 print (
"Searching for compatible TCT directories ..." )
140 for tctname
in names:
141 if (tctname.startswith(
"LatestRun")
or tctname.endswith(
"_MP")
or tctname.endswith(
"IDCosmic0")
or tctname.endswith(
"_PHYSVAL")
or tctname.endswith(
"Derived_Outputs")):
142 print (
"skipping "+tctname)
155 formats = [
"RDO",
"ESD",
"AOD",
"TAG"]
158 if refEvents
is None or len(refEvents) == 0:
159 print (
"No events found in",ref.logfile)
164 if valEvents
is None or len(valEvents) == 0:
165 print (
"No events found in", val.logfile)
168 if (valEvents == refEvents):
169 for file
in refEvents:
170 allEvents += refEvents[file]
171 print (
"TCT %s output seems compatible for ref and chk:" % (tctname))
172 for format
in refEvents:
173 print (
"%-70s: ref: %d events, val: %d events" % (format, refEvents[format], valEvents[format]))
176 print (
"The (names of the) output files differ in some way:")
179 print (
"Will now attempt to match the files by type")
181 for refFormat
in refEvents:
185 for vFormat
in valEvents:
190 if f
in refFormat
and f
in vFormat:
192 print (
"Both are %s: %s, %s" % (f, refFormat, valFormat))
194 print (
" %s, ref: %d, val: %d" % (format, refEvents[refFormat], valEvents[valFormat]))
198 print (
"TCT %s is NOT compatible, outputs different number of events for at least one format:" % tctname)
201 print (
"Found %i compatible TCT chains with at total of %i events" % (len(self.
_commonDirs), allEvents))
209 pattern=re.compile(filename)
213 if len(pattern.findall(f)):
215 self.
addNew(result,dir+
"/"+f)
216 if "rttjobinfo.xml" in ls:
218 for f
in castorfiles:
228 for (name,(ref,val))
in six.iteritems (self.
_commonDirs):
235 rfN=rf.split(
"/")[-1]
238 vfN=vf.split(
"/")[-1]
240 result[name]+=((rf,vf),)
249 dom=
parse(rttxmlfile)
250 archfiles=dom.getElementsByTagName(
"archivefile")
252 cpEle=af.getElementsByTagName(
"destination")
255 s = af.firstChild.nodeValue
256 json_acceptable_string = s.replace(
"'",
"\"")
257 d = json.loads(json_acceptable_string)
260 castorpath=cpEle[0].childNodes[0].data.strip()
262 if len(pattern.findall(castorpath)):
269 if __name__==
"__main__":
271 print (
"Find compatible pairs of TCT files")
272 print (
"Usage example")
273 print (sys.argv[0],
"15.6.X.Y rel_1 15.6.X.Y-VAL rel_2 'myTAGCOMM.*root'")
275 if len(sys.argv) != 6:
282 if not os.access(rPath,os.R_OK):
283 print (
"Can't access output of reference TCT at",rPath)
286 if not os.access(vPath,os.R_OK):
287 print (
"Can't access output of reference TCT at",vPath)
290 pattern=re.compile(sys.argv[5])
293 tctlist=ff.getCommonChains()
295 res=ff.findFiles(pattern)
296 for name,fl
in six.iteritmes (res):