|
def | __init__ (self, rDir, vDir, checkAge=False) |
|
def | checkFileAge (self, path) |
|
def | hasLogfile (self, ref, p, fl) |
|
def | addNew (self, fileList, file) |
|
def | findBetween (self, s, first, last) |
|
def | getTCTChainInfo (self, tci) |
|
def | getChains (self) |
|
def | getCommonChains (self) |
|
def | findFilesInDir (self, dir, filename) |
|
def | findFiles (self, pattern) |
|
def | extractCastorPath (self, rttxmlfile, pattern) |
|
Definition at line 32 of file getFileLists.py.
◆ __init__()
def python.getFileLists.findTCTFiles.__init__ |
( |
|
self, |
|
|
|
rDir, |
|
|
|
vDir, |
|
|
|
checkAge = False |
|
) |
| |
Definition at line 33 of file getFileLists.py.
33 def __init__(self, rDir, vDir, checkAge = False):
34 self._checkAge = checkAge
37 self._commonDirs = dict()
◆ addNew()
def python.getFileLists.findTCTFiles.addNew |
( |
|
self, |
|
|
|
fileList, |
|
|
|
file |
|
) |
| |
Definition at line 73 of file getFileLists.py.
73 def addNew(self,fileList,file):
74 newSplit=file.split(
"/")
75 newStream=newSplit[-3]
78 oldSplit=old.split(
"/")
79 if oldSplit[-1]==newFile
and oldSplit[-3]==newStream:
◆ checkFileAge()
def python.getFileLists.findTCTFiles.checkFileAge |
( |
|
self, |
|
|
|
path |
|
) |
| |
Definition at line 41 of file getFileLists.py.
41 def checkFileAge(self,path):
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.)))
◆ extractCastorPath()
def python.getFileLists.findTCTFiles.extractCastorPath |
( |
|
self, |
|
|
|
rttxmlfile, |
|
|
|
pattern |
|
) |
| |
Definition at line 247 of file getFileLists.py.
247 def extractCastorPath(self,rttxmlfile,pattern):
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)):
◆ findBetween()
def python.getFileLists.findTCTFiles.findBetween |
( |
|
self, |
|
|
|
s, |
|
|
|
first, |
|
|
|
last |
|
) |
| |
Definition at line 85 of file getFileLists.py.
85 def findBetween(self, s, first, last ):
87 start = s.index( first ) + len( first )
88 end = s.index( last, start )
◆ findFiles()
def python.getFileLists.findTCTFiles.findFiles |
( |
|
self, |
|
|
|
pattern |
|
) |
| |
Definition at line 222 of file getFileLists.py.
224 if len(self._commonDirs)==0:
225 self.getCommonChains()
228 for (name,(ref,val))
in six.iteritems (self._commonDirs):
229 reffiles=self.findFilesInDir(ref.directory,pattern)
230 valfiles=self.findFilesInDir(val.directory,pattern)
235 rfN=rf.split(
"/")[-1]
238 vfN=vf.split(
"/")[-1]
240 result[name]+=((rf,vf),)
◆ findFilesInDir()
def python.getFileLists.findTCTFiles.findFilesInDir |
( |
|
self, |
|
|
|
dir, |
|
|
|
filename |
|
) |
| |
Definition at line 207 of file getFileLists.py.
207 def findFilesInDir(self,dir,filename):
209 pattern=re.compile(filename)
213 if len(pattern.findall(f)):
215 self.addNew(result,dir+
"/"+f)
216 if "rttjobinfo.xml" in ls:
217 castorfiles=self.extractCastorPath(dir+
"/rttjobinfo.xml",pattern)
218 for f
in castorfiles:
219 self.addNew(result,f)
◆ getChains()
def python.getFileLists.findTCTFiles.getChains |
( |
|
self | ) |
|
Definition at line 124 of file getFileLists.py.
125 print (
"Input directory:",self._rDir)
126 print (
"Searching for TCT sub-directories")
127 os.path.walk(self._rDir,self.hasLogfile,
True)
128 print (
"Found ",len(self._commonDirs),
"directories")
129 return self._commonDirs
◆ getCommonChains()
def python.getFileLists.findTCTFiles.getCommonChains |
( |
|
self | ) |
|
Definition at line 132 of file getFileLists.py.
132 def getCommonChains(self):
133 print (
"Searching for compatible TCT directories ..." )
136 os.path.walk(self._rDir, self.hasLogfile,
True)
137 os.path.walk(self._vDir, self.hasLogfile,
False)
139 names = self._commonDirs.
keys()
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)
143 self._commonDirs.pop(tctname)
146 tcis = self._commonDirs[tctname]
149 self._commonDirs.pop(tctname)
155 formats = [
"RDO",
"ESD",
"AOD",
"TAG"]
157 refEvents = self.getTCTChainInfo(ref)
158 if refEvents
is None or len(refEvents) == 0:
159 print (
"No events found in",ref.logfile)
160 self._commonDirs.pop(tctname)
163 valEvents = self.getTCTChainInfo(val)
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]))
197 self._commonDirs.pop(tctname)
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))
204 return self._commonDirs
◆ getTCTChainInfo()
def python.getFileLists.findTCTFiles.getTCTChainInfo |
( |
|
self, |
|
|
|
tci |
|
) |
| |
Definition at line 93 of file getFileLists.py.
93 def getTCTChainInfo(self,tci):
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
◆ hasLogfile()
def python.getFileLists.findTCTFiles.hasLogfile |
( |
|
self, |
|
|
|
ref, |
|
|
|
p, |
|
|
|
fl |
|
) |
| |
Definition at line 53 of file getFileLists.py.
53 def hasLogfile(self,ref,p,fl):
58 if os.path.isfile(logpath)
and f.endswith(
"_log")
and not f.endswith(
"_script_log"):
61 tci=TCTChainInfo(p,logpath)
63 if name
in self._commonDirs:
64 print (
"ERROR: Duplicate directory name",name)
66 self._commonDirs[name]=(tci,)
68 if name
in self._commonDirs:
69 self._commonDirs[name]+=(tci,)
◆ _checkAge
python.getFileLists.findTCTFiles._checkAge |
|
private |
◆ _commonDirs
python.getFileLists.findTCTFiles._commonDirs |
|
private |
◆ _rDir
python.getFileLists.findTCTFiles._rDir |
|
private |
◆ _rFiles
python.getFileLists.findTCTFiles._rFiles |
|
private |
◆ _vDir
python.getFileLists.findTCTFiles._vDir |
|
private |
◆ _vFiles
python.getFileLists.findTCTFiles._vFiles |
|
private |
The documentation for this class was generated from the following file: