11 from __future__
import print_function
16 from xml.etree
import ElementTree
20 counter, cmask, invmask, sampling_period, startatevent, storeresultsat, family
22 cmask =
map(int, cmask)
23 invmask =
map(int, invmask)
24 sampling_period =
map(int, sampling_period)
25 startatevent = int(startatevent)
27 from Configurables
import ApplicationMgr, AuditorSvc, PerfMonAuditor
30 app.AuditAlgorithms = 1
33 pfaud.EVENT0 = counter[0]
34 pfaud.SP0 = sampling_period[0]
35 pfaud.INV0 = int(invmask[0])
36 pfaud.CMASK0 = int(cmask[0])
37 pfaud.EVENT1 = counter[1]
38 pfaud.SP1 = sampling_period[1]
39 pfaud.INV1 = int(invmask[1])
40 pfaud.CMASK1 = int(cmask[1])
41 pfaud.EVENT2 = counter[2]
42 pfaud.SP2 = sampling_period[2]
43 pfaud.INV2 = int(invmask[2])
44 pfaud.CMASK2 = int(cmask[2])
45 pfaud.EVENT3 = counter[3]
46 pfaud.SP3 = sampling_period[3]
47 pfaud.INV3 = int(invmask[3])
48 pfaud.CMASK3 = int(cmask[3])
53 pfaud.PREFIX =
"%s_%s" % (storeresultsat,
"S" if sampling_period[0] > 0
else "C")
54 pfaud.SAMPLE = int(sampling_period[0] > 0)
55 pfaud.START_AT_EVENT = startatevent
63 Adds object like functionality to the standard dictionary.
69 dict.__init__(self, initdict)
72 return self.__getitem__(item)
75 self.__setitem__(item, value)
79 return self.__getitem__(
"_text")
86 Static method to wrap a dictionary recursively as an XmlDictObject
89 if isinstance(x, dict):
90 return XmlDictObject((k, XmlDictObject.Wrap(v))
for (k, v)
in x.iteritems())
91 elif isinstance(x, list):
92 return [XmlDictObject.Wrap(v)
for v
in x]
98 if isinstance(x, dict):
99 return dict((k, XmlDictObject._UnWrap(v))
for (k, v)
in x.iteritems())
100 elif isinstance(x, list):
101 return [XmlDictObject._UnWrap(v)
for v
in x]
107 Recursively converts an XmlDictObject to a standard dictionary and returns the result.
110 return XmlDictObject._UnWrap(self)
114 assert type(dictitem)
is not type([])
116 if isinstance(dictitem, dict):
117 for (tag, child)
in dictitem.iteritems():
118 if str(tag) ==
"_text":
119 parent.text = str(child)
122 for listchild
in child:
123 elem = ElementTree.Element(tag)
127 elem = ElementTree.Element(tag)
131 parent.text = str(dictitem)
136 Converts a dictionary to an XML ElementTree Element
139 roottag = xmldict.keys()[0]
140 root = ElementTree.Element(roottag)
146 nodedict = dictclass()
148 if len(node.items()) > 0:
150 nodedict.update(dict(node.items()))
155 if child.tag
in nodedict:
157 if type(nodedict[child.tag])
is type([]):
159 nodedict[child.tag].append(newitem)
162 nodedict[child.tag] = [nodedict[child.tag], newitem]
165 nodedict[child.tag] = newitem
167 if node.text
is None:
170 text = node.text.strip()
172 if len(nodedict) > 0:
175 nodedict[
"_text"] = text
185 Converts an XML file or ElementTree Element to a dictionary
190 root = ElementTree.parse(root).getroot()
191 elif not isinstance(root, ElementTree.Element):
192 raise TypeError(
"Expected ElementTree.Element or file path string")