13if __name__ ==
"__main__":
15 parser = argparse.ArgumentParser(description=
'Coolr browser.', add_help=
False)
16 parser.add_argument(
'--input', required=
True,help=
'Input file in text folrat. It is output of athena job. It require has lines with info about load data: INFO Retrieved object: folder ')
17 parser.add_argument(
'--gtag', required=
True,
18 help=
'Global tag for CREST')
19 parser.add_argument(
'--gcooltag', required=
True,
20 help=
'Global tag for COOL')
21 parser.add_argument(
'--host', default=
'http://crest-j23.cern.ch',
22 help=
'Host of the CREST service (default: http://crest-j23.cern.ch)')
23 parser.add_argument(
'--port', default=
'8080',
24 help=
'Port of the CREST service (default: 8080)')
25 parser.add_argument(
'--out', default=
'log.out',
26 help=
'Out file for logs (default: log.out)')
27 parser.add_argument(
'--path', default=
'cool_crest_compare',
28 help=
'Path to compare (default: cool_crest_compare)')
29 parser.add_argument(
'--debug', action=argparse.BooleanOptionalAction, help=
'Set debug output')
31 args = parser.parse_args()
32 server =
"{0}:{1}".format(args.host, args.port)
37 if not path.exists(args.input)
or not path.isfile(args.input):
38 print(
"Error: input file is not exists")
44 with open(args.input)
as inp_file:
45 while line := inp_file.readline():
46 if line.rstrip().
find(
'/TagInfo<metaOnly/>')>0:
53 sTag=e[e.find(
'<tag>')+5:]
54 if sTag.find(
'</tag>')>0:
55 sTag=sTag[:sTag.find(
'</tag>')]
57 db=e[e.find(
'<db>')+4:]
58 db=db[:db.find(
'</db>')]
60 e=e[e.find(
'</db>')+5:]
61 folder = e[e.find(
'/'):]
62 if folder.find(
'<')>-1:
63 folder = folder[:folder.find(
'<')]
64 elif folder.find(
' ')>-1:
65 folder = folder[:folder.find(
' ')]
67 folder = folder[:folder.find(
'\'')]
69 data[folder.strip()]=el
70 if line.rstrip().
find(
'Using tag ')>0:
71 st = line.rstrip()[line.rstrip().
find(
'Using tag ')+10:]
72 sTag = st[:st.find(
' ')]
73 if st.rstrip().
find(
'for folder ')>0:
74 st = st.rstrip()[st.rstrip().
find(
'for folder '):]
75 st = st[st.find(
'/'):]
77 el = data[sFolder.strip()]
79 data[sFolder.strip()]=el
80 if line.rstrip().
find(
' is requested but no data retrieved')>0:
81 st = line.rstrip()[:line.rstrip().
find(
' is requested but no data retrieved')]
82 st = st[st.find(
'WARNING Folder')+14:]
83 noUsedData.append(st.strip())
84 if line.rstrip().
find(
'Retrieved object: folder ')>0:
85 st = line.rstrip()[line.rstrip().
find(
'Retrieved object: folder '):]
86 st = st[st.find(
'/'):]
87 sFolder = st[:st.find(
' ')]
88 st= st[st.find(
'IOV ')+4:]
90 el = data[sFolder.strip()]
92 data[sFolder.strip()]=el
95 print(
"List of commands for compare:")
97 for elem
in data.keys():
99 if 'timestamp' not in js:
101 command = appPath +
' -g '+ args.gtag+
' -G '+args.gcooltag+
' -f '+elem +
' -c "'+ js[
'db']+
'" -t ' + js[
'timestamp']+
' -C '+server
103 if js[
'tag'].
find(
'HEAD')>=0:
106 command +=
' -T '+js[
'tag']
107 command +=
' >>'+fOut+
' 2>&1'
109 with open(fOut,
'a')
as f:
110 print(
'Compare folder name:', elem, file=f)
111 print(command,file=f)
114 print(
"Problem folders:")
124 with open(fOut)
as log_file:
125 while line := log_file.readline():
126 if line.find(
'Compare folder name:')>-1:
129 command = appPath +
' -g '+ args.gtag+
' -G '+args.gcooltag+
' -f '+ curFolder +
' -c '+ js[
'db']+
' -t ' + js[
'timestamp']+
' -C '+server
131 if js[
'tag'].
find(
'HEAD')>=0:
134 command +=
' -T '+js[
'tag']
137 crestProblem.append(curFolder)
139 coolProblem.append(curFolder)
141 unknowProblem.append(curFolder)
143 curFolder=line.rstrip()[line.rstrip().
find(
'Compare folder name:')+20:]
144 curFolder=curFolder.lstrip()
145 allFolder.append(curFolder)
146 elif line.rstrip().
find(
'is the same in COOL and CREST')>0:
147 correctFolder.append(curFolder)
149 elif line.rstrip().
find(
'Start COOL dump:')>-1:
152 elif line.rstrip().
find(
'Start CREST dump:')>-1:
155 elif line.find(
'CREST output file problem')>-1:
157 crestProblem.append(curFolder)
158 elif line.find(
'COOL output file problem')>-1:
160 coolProblem.append(curFolder)
161 elif line.rstrip().
find(
'is different in COOL and CREST')>0:
162 fld = line.rstrip()[line.rstrip().
find(
'\"')+1:]
163 fld = fld[:fld.find(
'\"')]
164 difFolder.append(fld)
166 command = appPath +
' -g '+ args.gtag+
' -G '+args.gcooltag+
' -f '+ fld +
' -c '+ js[
'db']+
' -t ' + js[
'timestamp']+
' -C '+server
168 if js[
'tag'].
find(
'HEAD')>=0:
171 command +=
' -T '+js[
'tag']
174 unCompared=data.keys()-allFolder
176 print(
"Total number of folders in logs:",len(data),
"; Total number of folders which compare (used):",len(allFolder),
"; Total number of unread folders:", len(noUsedData),
"; Correct folders:",len(correctFolder),
"; Different folders:",len(difFolder),
"; COOL problems:",len(coolProblem),
"; CREST problems:",len(crestProblem),
"; Unknown problems:", len(unknowProblem))
178 print(
"Different data:",difFolder)
179 if len(coolProblem)>0:
180 print(
"COOL problem folders:",coolProblem)
181 if len(crestProblem)>0:
182 print(
"CREST problem folders:",crestProblem)
183 if len(unknowProblem)>0:
184 print(
"Unknown problem folders:",unknowProblem)
187 print(
"Incomparable folders:",unCompared)
188 if len(noUsedData)>0:
189 print(
"Unread (Unused) folders:",noUsedData)
190 elif len(noUsedData)>0:
191 print(
"Unread (Unused) folders:",noUsedData)
192 if len(correctFolder)>0
and args.debug:
193 print(
"Correct folders:",correctFolder)
194 if len(allFolder)>0
and args.debug:
195 print(
"Full folder list:",allFolder)
197 print(
"Total list folders in log:",list(data.keys()))
void print(char *figname, TCanvas *c1)
std::string find(const std::string &s)
return a remapped string
std::vector< std::string > split(const std::string &s, const std::string &t=":")