3 ExtracAppInfoFromXML [-sapc] file 5 file file from where to read a RCMS configuration 6 -s list application servers found in the XML file 7 -p list the ports used found in the XML file 8 -a list the names of the applications configured in the XML file 9 -c list the cfg (eg dqmfu09-1_cfg.py) files 11 The default behavior is to present a table organized in the following way 12 SERVER PORT CFG_FILE APP_NAME 13 which is equivalent to using -sapc 15 The options selected and their order will affect teeh fields shown and their 16 respective sorting. eg. 17 -sa will only show SERVER and APP_NAME and will sort first by SERVER and 20 OUTPUT is always unique in a per row bases 22 from __future__
import print_function
25 from xml.dom
import minidom
35 print(
"[%d-%d-%d]"%(l,bn,head.nodeType)+tabs+
"+++++>"+head.tagName)
36 except AttributeError
as e:
37 print(
"[%d-%d-%d]"%(l,bn,head.nodeType)+tabs+
"+++++>"+
str(e))
38 print(
"[%d-%d-%d-v]"%(l,bn,head.nodeType)+tabs+
"."+ (head.nodeValue
or "None"))
40 for katt,vatt
in head.attributes.items():
41 if katt!=
"environmentString":
42 print(tabs+
"%s=%s"%(katt,vatt))
44 print(tabs+
"%s= 'Some Stuff'"%(katt,))
48 for node
in head.childNodes:
54 for item
in head.childNodes:
55 if item.nodeType == 3:
60 for item
in head.childNodes[1:]:
61 if item.nodeType == 3:
62 firstborne.nodeValue+=item.nodeValue
67 """Parses information that's XML format from value to the Docuemnt tree""" 69 if head.firstChild.nodeValue:
70 newNode=minidom.parseString(head.firstChild.nodeValue)
71 for node
in newNode.childNodes:
72 head.appendChild(node.cloneNode(
True))
76 """it searches for the line containing the string consumerName, usually 77 found as a property of the process, and returns the set value found. 80 process.EventStreamHttpReader.consumerName = 'EcalEndcap DQM Consumer' 82 EcalEndcap DQM Consumer 86 consumer = f.readline()
89 consumer=consumer.strip()
90 if "consumerName" in consumer:
91 name=consumer[consumer.index(
"'")+1:consumer.index(
"'",consumer.index(
"'")+1)]
93 consumer = f.readline()
96 sys.stderr.write(
"WARNING: Unable to open file: " + filename +
" from <configFile> section of XML\n")
97 name =
"CONFIG FILE IS M.I.A" 101 """it searches for the line containing the string consumerName, usually 102 found as a property of the process, and returns the set value found. 105 process = cms.Process ("ECALDQM") 112 sys.stderr.write(
"Unable to open file: " + filename +
" from <configFile> section of XML\n")
114 consumer = f.readline()
117 consumer=consumer.strip()
118 if "cms.Process(" in consumer:
119 name=consumer[consumer.index(
"(")+2:consumer.index(
")")-1]
121 consumer = f.readline()
127 branch=branch1[:len(branch1)]
129 for item
in range(len(nodeList)):
130 vals=[v
for (k,v)
in nodeList[idx].attributes.items()]
131 if branch[0]
not in vals:
136 elif len(branch1)==0:
146 key=
min(order.keys())
150 lista=xmldoc.getElementsByTagName(
"XdaqExecutive")
153 table[item.attributes[
"hostname"].value]=
"" 154 for item
in table.keys():
155 table[item]=
fillTable(order.copy(),branch + [item])
157 lista=xmldoc.getElementsByTagName(
"XdaqExecutive")
160 pset=item.getElementsByTagName(
"parameterSet")
162 arch=pset[0].firstChild.nodeValue[5:]
166 App=item.getElementsByTagName(
"xc:Application")
167 table[App[0].attributes[
"class"].value]=
"" 168 for item
in table.keys():
169 table[item]=
fillTable(order.copy(),branch)
171 lista=xmldoc.getElementsByTagName(
"XdaqExecutive")
174 table[item.attributes[
"port"].value]=
"" 175 for item
in table.keys():
176 table[item]=
fillTable(order.copy(),branch + [item])
178 lista=xmldoc.getElementsByTagName(
"XdaqExecutive")
181 pset=item.getElementsByTagName(
"parameterSet")
183 table[
"No additional file"]=
"" 185 table[pset[0].firstChild.nodeValue]=
"" 186 for item
in table.keys():
187 table[item]=
fillTable(order.copy(),branch)
193 """table => {s:{p:{c:{a:{}}}}}""" 195 for (server,ports)
in table.items():
196 for (port,configfiles)
in ports.items():
197 for (configfile,appnames)
in configfiles.items():
198 for appname
in appnames.keys():
200 for col
in order.values():
206 line.append(configfile)
217 for col
in range(numcols):
220 for col
in range(numcols):
221 if len(line[col])>maxs[col]:
222 maxs[col]=len(line[col])
225 for col
in range(numcols):
226 pline+=line[col].ljust(maxs[col]+2)
233 """ getAppInfo(XMLf,s=0,a=2,p=1,c=3) takes the file name of a valid RCMS 234 configuration and 4 variables that represent which fields are desired 237 It returns a touple containing a directory that contains all the 238 relevant information in the XMLf file and a list of rows each row 239 containing the fiels specified by the other four variables in the r 242 The fields are Servers (s) ports(p) Appnames a.k.a. consumer names(a) 243 and consumer config file. (Note: The consumerName is directly extracted 244 from the config file.) if one field is not desired it should be assigned 245 a value of -1 eg s=-1. other wise their value is mapped from smallest to 246 largest ==> left to right. Note the default values, they will take 247 precedence if not specifyed giving unexpected results 253 sys.stderr.write(
'File doesn\'t exist\n')
256 xmldoc = minidom.parse(XMLf)
258 sys.stderr.write(
'Unable to locate file ' +XMLf +
'\n')
261 sys.stderr.write(
'Parser error\n')
264 configFileNodes=xmldoc.getElementsByTagName(
"configFile")
265 for node
in configFileNodes:
268 order={0:
"s",1:
"p",3:
"a",2:
"c"}
290 if __name__ ==
"__main__":
296 if arg.startswith(
"-"):
297 options+=arg.strip(
"-")
300 if options.count(
"s")+options.count(
"a")+options.count(
"p")+options.count(
"c")!=len(options):
301 sys.stderr.write(
"Sintax Error unrecognised option" )
302 sys.stderr.write( __doc__ )
304 if options.count(
"s")+options.count(
"a")+options.count(
"p")+options.count(
"c")==0:
307 (apptable,appinfo)=
getAppInfo(XMLfile,options.find(
"s"),options.find(
"a"),options.find(
"p"),options.find(
"c"))
S & print(S &os, JobReport::InputFile const &f)