CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
ExtractAppInfoFromXML Namespace Reference

Functions

def appendDataXML
 
def compactNodeValue
 
def fillTable
 
def filterNodeList
 
def getAppInfo
 getAppInfo # More...
 
def getAppNameFromCfg
 
def getProcNameFromCfg
 
def printGrid
 
def printXMLtree
 
def SortAndGrid
 

Variables

 args = sys.argv
 
string options = ""
 
string xmldoc = ""
 Some module's global variables. More...
 
string XMLfile = ""
 

Function Documentation

def ExtractAppInfoFromXML.appendDataXML (   head)
Parses information that's XML format from value to the Docuemnt tree

Definition at line 65 of file ExtractAppInfoFromXML.py.

References compactNodeValue().

Referenced by getAppInfo().

65 
66 def appendDataXML(head):
67  """Parses information that's XML format from value to the Docuemnt tree"""
68  compactNodeValue(head)
69  if head.firstChild.nodeValue:
70  newNode=minidom.parseString(head.firstChild.nodeValue)
71  for node in newNode.childNodes:
72  head.appendChild(node.cloneNode(True))
newNode.unlink()
def ExtractAppInfoFromXML.compactNodeValue (   head)

Definition at line 51 of file ExtractAppInfoFromXML.py.

Referenced by appendDataXML().

51 
52 def compactNodeValue(head):
53  firstborne=None
54  for item in head.childNodes:
55  if item.nodeType == 3:
56  firstborne = item
57  break
58  if not firstborne:
59  return
60  for item in head.childNodes[1:]:
61  if item.nodeType == 3:
62  firstborne.nodeValue+=item.nodeValue
63  item.nodeValue=None
def ExtractAppInfoFromXML.fillTable (   order,
  branch = [] 
)

Definition at line 140 of file ExtractAppInfoFromXML.py.

References filterNodeList(), getAppNameFromCfg(), getProcNameFromCfg(), and min().

Referenced by getAppInfo().

141 def fillTable(order,branch=[]):
142  global xmldoc
143  table={}
144  if len(order)==0:
145  return table
146  key=min(order.keys())
147  k=order[key]
148  order.pop(key)
149  if k=="s":
150  lista=xmldoc.getElementsByTagName("XdaqExecutive")
151  lista=filterNodeList(branch,lista)
152  for item in lista:
153  table[item.attributes["hostname"].value]=""
154  for item in table.keys():
155  table[item]=fillTable(order.copy(),branch + [item])
156  elif k=="a":
157  lista=xmldoc.getElementsByTagName("XdaqExecutive")
158  lista=filterNodeList(branch,lista)
159  for item in lista:
160  pset=item.getElementsByTagName("parameterSet")
161  if len(pset):
162  arch=pset[0].firstChild.nodeValue[5:]
163  appname=getAppNameFromCfg(arch) or getProcNameFromCfg(arch)
164  table[appname]=""
165  else:
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)
170  elif k=="p":
171  lista=xmldoc.getElementsByTagName("XdaqExecutive")
172  lista=filterNodeList(branch,lista)
173  for item in lista:
174  table[item.attributes["port"].value]=""
175  for item in table.keys():
176  table[item]=fillTable(order.copy(),branch + [item])
177  elif k=="c":
178  lista=xmldoc.getElementsByTagName("XdaqExecutive")
179  lista=filterNodeList(branch,lista)
180  for item in lista:
181  pset=item.getElementsByTagName("parameterSet")
182  if not len(pset):
183  table["No additional file"]=""
184  else:
185  table[pset[0].firstChild.nodeValue]=""
186  for item in table.keys():
187  table[item]=fillTable(order.copy(),branch)
188  else:
189  pass
return table
T min(T a, T b)
Definition: MathUtil.h:58
def ExtractAppInfoFromXML.filterNodeList (   branch1,
  nodeList 
)

Definition at line 124 of file ExtractAppInfoFromXML.py.

Referenced by fillTable().

125 def filterNodeList(branch1,nodeList):
126  if len(branch1) > 0:
127  branch=branch1[:len(branch1)]
128  idx=0
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:
132  del nodeList[idx]
133  else:
134  idx=idx+1
135  del branch[0]
136  elif len(branch1)==0:
137  return nodeList
138  return filterNodeList(branch,nodeList)
def ExtractAppInfoFromXML.getAppInfo (   XMLf,
  s = 0,
  a = 2,
  p = 1,
  c = 3 
)

getAppInfo #

getAppInfo(XMLf,s=0,a=2,p=1,c=3) takes the file name of a valid RCMS 
    configuration and 4 variables that represent which fields are desired 
    and in which order. 
    
    It returns a touple containing a directory that contains all the 
    relevant information in the XMLf file and a list of rows each row 
    containing the fiels specified by the other four variables in the r
    espective order
    
    The fields are Servers (s) ports(p) Appnames a.k.a. consumer names(a) 
    and consumer config file. (Note: The consumerName is directly extracted 
    from the config file.) if one field is not desired it should be assigned
    a value of -1 eg s=-1. other wise their value is mapped from smallest to
    largest ==> left to right. Note the default values, they will take 
    precedence if not specifyed giving unexpected results

Definition at line 231 of file ExtractAppInfoFromXML.py.

References appendDataXML(), fillTable(), and SortAndGrid().

232 def getAppInfo(XMLf,s=0,a=2,p=1,c=3):
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
235  and in which order.
236 
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
240  espective order
241 
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
248  """
249  global xmldoc
250  try:
251  os.path.exists(XMLf)
252  except:
253  sys.stderr.write('File doesn\'t exist\n')
254  sys.exit(2)
255  try:
256  xmldoc = minidom.parse(XMLf)
257  except IOError:
258  sys.stderr.write('Unable to locate file ' +XMLf +'\n')
259  return ({},[])
260  except:
261  sys.stderr.write('Parser error\n')
262  return ({},[])
263 
264  configFileNodes=xmldoc.getElementsByTagName("configFile")
265  for node in configFileNodes:
266  appendDataXML(node)
267  ## The table is always filled in a specific order, to properly get the data
268  order={0:"s",1:"p",3:"a",2:"c"}
269  #try:
270  table=fillTable(order)
271  #except:
272  # return ({},[])
273  del order
274  order={}
275  if a != -1:
276  order[a]="a"
277  if c != -1:
278  order[c]="c"
279  if s != -1:
280  order[s]="s"
281  if p != -1:
282  order[p]="p"
283  grid=SortAndGrid(table,order)
284  #printXMLtree(xmldoc)
285  #Clean Up
286  xmldoc.unlink()
287  return (table,grid)
def ExtractAppInfoFromXML.getAppNameFromCfg (   filename)
it searches for the line containing the string consumerName, usually
found as a property of the process, and returns the set value found.
eg. 
matches line:
    process.EventStreamHttpReader.consumerName = 'EcalEndcap DQM Consumer' 
returns:
    EcalEndcap DQM Consumer 

Definition at line 74 of file ExtractAppInfoFromXML.py.

Referenced by fillTable().

74 
75 def getAppNameFromCfg(filename):
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.
78  eg.
79  matches line:
80  process.EventStreamHttpReader.consumerName = 'EcalEndcap DQM Consumer'
81  returns:
82  EcalEndcap DQM Consumer
83  """
84  try:
85  f = open(filename)
86  consumer = f.readline()
87  name=""
88  while consumer :
89  consumer=consumer.strip()
90  if "consumerName" in consumer:
91  name=consumer[consumer.index("'")+1:consumer.index("'",consumer.index("'")+1)]
92  break
93  consumer = f.readline()
94  f.close()
95  except:
96  sys.stderr.write("WARNING: Unable to open file: " + filename + " from <configFile> section of XML\n")
97  name = "CONFIG FILE IS M.I.A"
return name
def ExtractAppInfoFromXML.getProcNameFromCfg (   filename)
it searches for the line containing the string consumerName, usually
found as a property of the process, and returns the set value found.
eg. 
matches line:
    process = cms.Process ("ECALDQM") 
returns:
    ECALDQM

Definition at line 99 of file ExtractAppInfoFromXML.py.

Referenced by fillTable().

99 
100 def getProcNameFromCfg(filename):
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.
103  eg.
104  matches line:
105  process = cms.Process ("ECALDQM")
106  returns:
107  ECALDQM
108  """
109  try:
110  f = open(filename)
111  except:
112  sys.stderr.write("Unable to open file: " + filename + " from <configFile> section of XML\n")
113  raise IOError
114  consumer = f.readline()
115  name=""
116  while consumer :
117  consumer=consumer.strip()
118  if "cms.Process(" in consumer:
119  name=consumer[consumer.index("(")+2:consumer.index(")")-1]
120  break
121  consumer = f.readline()
122  f.close()
return name
def ExtractAppInfoFromXML.printGrid (   grid)

Definition at line 212 of file ExtractAppInfoFromXML.py.

213 def printGrid(grid):
214  numcols=len(grid[0])
215  PPGrid=grid[:]
216  maxs=[]
217  for col in range(numcols):
218  maxs.append(0)
219  for line in grid:
220  for col in range(numcols):
221  if len(line[col])>maxs[col]:
222  maxs[col]=len(line[col])
223  for line in PPGrid:
224  pline=""
225  for col in range(numcols):
226  pline+=line[col].ljust(maxs[col]+2)
227  print pline
def ExtractAppInfoFromXML.printXMLtree (   head,
  l = 0,
  bn = 0 
)

Definition at line 29 of file ExtractAppInfoFromXML.py.

29 
30 def printXMLtree(head,l=0,bn=0):
31  tabs=""
32  for a in range(l):
33  tabs+="\t"
34  try:
35  print "[%d-%d-%d]"%(l,bn,head.nodeType)+tabs+"+++++>"+head.tagName
36  except AttributeError, 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")
39  try:
40  for katt,vatt in head.attributes.items():
41  if katt!="environmentString":
42  print tabs+"%s=%s"%(katt,vatt)
43  else:
44  print tabs+"%s= 'Some Stuff'"%(katt,)
45  except:
46  pass
47  i=0
48  for node in head.childNodes:
49  printXMLtree(node,l+1,i)
i+=1
def ExtractAppInfoFromXML.SortAndGrid (   table,
  order 
)
table => {s:{p:{c:{a:{}}}}}

Definition at line 191 of file ExtractAppInfoFromXML.py.

Referenced by getAppInfo().

192 def SortAndGrid(table,order):
193  """table => {s:{p:{c:{a:{}}}}}"""
194  grid=[]
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():
199  line=[]
200  for col in order.values():
201  if col=="s":
202  line.append(server)
203  if col=="p":
204  line.append(port)
205  if col=="c":
206  line.append(configfile)
207  if col=="a":
208  line.append(appname)
209  grid.append(line)
210  grid.sort()
return grid

Variable Documentation

ExtractAppInfoFromXML.args = sys.argv

Definition at line 291 of file ExtractAppInfoFromXML.py.

Referenced by DQMStore::IBooker.book1D(), DQMStore::IBooker.book1DD(), DQMStore::IBooker.book1S(), DQMStore::IBooker.book2D(), DQMStore::IBooker.book2DD(), DQMStore::IBooker.book2S(), DQMStore::IBooker.book3D(), DQMStore::IBooker.bookFloat(), DQMStore::IBooker.bookInt(), DQMStore::IBooker.bookProfile(), DQMStore::IBooker.bookProfile2D(), DQMStore::IBooker.bookString(), Disk.build(), FWTabularWidget.buttonPressed(), FWTabularWidget.buttonReleased(), FWTableWidget.cellClicked(), FWTableWidget.columnClicked(), NavigationSchool.compatibleLayers(), edmplugin::PluginFactory< R *(Args...)>::PMaker< TPlug >.create(), edmplugin::PluginFactory< R *(Args...)>.create(), DQMGenericClient.DQMGenericClient(), DQMRivetClient.DQMRivetClient(), edm::signalslot::Signal< void(StreamID)>.emit(), TempTrajectory.emplace(), edm::ProcessHistory.emplace_back(), cmsutils::bqueue< TrajectoryMeasurement >.emplace_back(), reco.findMethod(), DQMStore::IGetter.getContents(), main(), NavigationSchool.nextLayers(), reco::parser::MethodSetter.operator()(), edm::serviceregistry::BlockingWrapper< Func >.operator()(), edm::signalslot::Signal< void(StreamID)>.operator()(), AnyMVAEstimatorRun2Base.packMVAVariables(), raiseDQMError(), DQMStore::IGetter.removeElement(), FWCollectionSummaryWidget.requestForModelContextMenu(), FWTableWidget.rowClicked(), TagProbeFitTreeAnalyzer.TagProbeFitTreeAnalyzer(), edmplugin::PluginFactory< R *(Args...)>.tryToCreate(), impl::MakeArray< T, N, I >.value(), and impl::MakeArray< T, N, 0 >.value().

string ExtractAppInfoFromXML.options = ""

Definition at line 293 of file ExtractAppInfoFromXML.py.

string ExtractAppInfoFromXML.xmldoc = ""

Some module's global variables.

Definition at line 27 of file ExtractAppInfoFromXML.py.

ExtractAppInfoFromXML.XMLfile = ""

Definition at line 290 of file ExtractAppInfoFromXML.py.