10 from libCatKernel
import *
12 from arguments
import *
31 return cat.current().child(path)
40 if (os.path.exists(filename) ==
False):
41 filename = filename +
".py" 42 if (os.path.exists(filename)):
45 cat.options().setDefFile(filename)
47 cat.warning(
"File " + filename +
" does not exist.",
"CAT")
51 filename = cat.options().defFile()
52 cat.computer().
clear()
58 element = cat.current()
60 element = cat.current().child(path)
61 if type(element) !=
None:
62 l = element.children()
63 for iter
in range(len(l)):
64 cat.info(
" " + l[iter].name() +
65 " [" + l[iter].type() +
"]",
"CAT")
66 cat.info(element.name() +
" : " + str(len(l)) +
67 " child(ren) found.",
"CAT")
72 element = cat.current()
74 element = cat.current().child(path)
75 if type(element) !=
None:
76 lproc = cat.procDb().list(element)
79 cat.info(
"- Processus: ",
"CAT")
80 for p
in range(nproc):
81 cat.info(
" " + lproc[p].name() +
82 " : " + lproc[p].title(),
"CAT")
83 l = element.children()
85 cat.info(
"- Element(s): ",
"CAT")
86 for iter
in range(len(l)):
87 cat.info(
" " + l[iter].name() +
88 " [" + l[iter].type() +
"]",
"CAT")
89 lproc = cat.procDb().list(l[iter])
90 for p
in range(len(lproc)):
91 cat.info(
" . " + lproc[p].name() +
92 " : " + lproc[p].title(),
"CAT")
93 cat.info(element.name() +
" : " + str(len(l)) +
" child(ren) found [" +
94 str(nproc) +
" processus].",
"CAT")
98 cat.info(cat.current().name() +
" [" + cat.current().type() +
"]",
"CAT")
103 element = cat.current()
105 element = cat.current().child(path)
106 if type(element) !=
None:
112 element = cat.current()
114 element = cat.current().child(path)
115 line = indent +
' -> ' + \
116 element.name() +
'[' + element.type() + \
117 ' - ' + element.attributs() +
']' 119 l = element.children()
120 for iter
in range(len(l)):
121 lproc = cat.procDb().list(l[iter])
122 for p
in range(len(lproc)):
123 print indent +
" ." + lproc[p].name() +
"(" + lproc[p].title() +
") - " + lproc[p].attributs()
124 view(l[iter].path(
''), indent +
' ')
132 if cat.create(object, type).isFailure():
133 cat.fatal(
"Could not make object " +
134 object +
" of type " + type,
"CAT")
141 list = cat.procDb().list()
142 for p
in range(len(list)):
143 if (list[p].name() == object):
146 cat.warning(
"Could not find processus " + object +
".",
"CAT")
152 list = cat.procDb().list()
153 for p
in range(len(list)):
154 if (list[p].name() == object):
157 list[p].
data().info()
159 return list[p].
data().vector(stream)
161 cat.warning(
"Could not find processus " + object +
".",
"CAT")
174 element = cat.current()
176 element = cat.current().child(path)
177 if type(element) !=
None:
183 cat.current().
clear()
185 cat.current().delChild(path)
189 levels = {
'VERBOSE': MsgLevel.VERBOSE,
190 'DEBUG': MsgLevel.DEBUG,
191 'INFO': MsgLevel.INFO,
192 'WARNING': MsgLevel.WARNING,
193 'FATAL': MsgLevel.FATAL}
194 outLevel = levels.get(level)
196 cat.options().setLogOutputLevel(outLevel)
198 cat.warning(
"Output Level should be 'VERBOSE', 'DEBUG', 'INFO', 'WARNING' or 'FATAL'",
200 cat.warning(
"'" + level +
"' level output not understood.",
"CAT")
204 cat.computer().recursiveInitCommunications()
205 cat.computer().recursiveInitElement()
209 cat.fatal(
"Not implemented.",
"CAT")
214 element = cat.current()
216 element = cat.current().child(path)
217 if type(element) !=
None:
222 current = cat.current()
224 sys.ps1 =
"\033[92m" + current.name() +
"\033[0m[\033[93m" + \
225 current.type() +
"\033[0m] > " 227 sys.ps1 =
"\033[91mInvalid\033[0m[\033[95mNone\033[0m] > " 231 cat.dllMgr().
load(name)
237 def run(processus, element, nevt):
238 if (type(element) == str):
239 element =
get(element)
240 if (element ==
None):
244 list = cat.procDb().list(element)
245 for p
in range(len(list)):
246 if (list[p].name() == processus):
250 cat.warning(
"Could not find processus " + processus +
".",
"CAT")
252 nrun =
opts().runNumber()
253 if (cat.prepare(processus, element, nevt).isFailure()):
254 cat.warning(
"Could not prepare the processus " +
255 processus +
".",
"CAT")
262 wrap =
wrapper(cat, proc,
"proc")
263 online = cat.options().plotFreq()
265 module = wrap.GetActive()
266 proc.setElement(element)
267 if module
and (online != 0):
268 plts = module.createPlots(cat, proc, nrun)
271 processus, end=abs(evt), width=width, fill=
'▣', blank=
'-')
274 if (evt<0): timing = time.time()
282 elapsed = time.time() - timing
284 if elapsed > evt : stop =
True 287 if ievt>=evt : stop =
True 289 if (cat.loop().isFailure()):
290 cat.warning(
"Error detected during processing.",
"CAT")
294 module.updatePlots(plts, proc)
295 except KeyboardInterrupt:
299 if module
and online==0:
300 plts = module.createPlots(cat, proc, nrun)
301 module.updatePlots(plts, proc)
341 if (
"" <> args.file):
342 if (os.path.exists(args.file)):
344 cat.options().setDefFile(args.file)
346 cat.fatal(
"Cannot execute init file " +
347 args.file +
". Abort.",
"CAT")
353 if __name__ ==
"__main__":
355 args.shellMode =
True
def run(processus, element, nevt)
def outputLevel(level='INFO')
def data(object, stream=None)
def view(path='', indent=' ')