Cat
Functions | Variables
shell Namespace Reference

Functions

def opts ()
 
def obj ()
 
def get (path)
 
def cd (path='')
 
def load (filename)
 
def reload ()
 
def ls (path='')
 
def ll (path='')
 
def pwd ()
 
def tree (path='')
 
def view (path='', indent=' ')
 
def create (object, type)
 
def process (object)
 
def data (object, stream=None)
 
def app ()
 
def clear (path='')
 
def delete (path='')
 
def outputLevel (level='INFO')
 
def init ()
 
def network ()
 
def reset (path='')
 
def prompt ()
 
def loadDll (name)
 
def run (processus, element, nevt)
 
def shell (app, args)
 

Variables

 args = arguments()
 
 shellMode
 

Function Documentation

◆ app()

def shell.app ( )

Definition at line 168 of file shell.py.

168 def app():
169  return cat
170 
171 
def app()
Definition: shell.py:168

◆ cd()

def shell.cd (   path = '')

Definition at line 34 of file shell.py.

References prompt().

34 def cd(path=''):
35  cat.cd(path)
36  prompt()
37 
38 
def prompt()
Definition: shell.py:221
def cd(path='')
Definition: shell.py:34

◆ clear()

def shell.clear (   path = '')

Definition at line 172 of file shell.py.

Referenced by delete(), AppFrame.AppFrame.onDelete(), and reload().

172 def clear(path=''):
173  if path == '':
174  element = cat.current()
175  else:
176  element = cat.current().child(path)
177  if type(element) != None:
178  element.clear()
179 
180 
def clear(path='')
Definition: shell.py:172

◆ create()

def shell.create (   object,
  type 
)

Definition at line 131 of file shell.py.

Referenced by Application.hostname().

131 def create(object, type):
132  if cat.create(object, type).isFailure():
133  cat.fatal("Could not make object " +
134  object + " of type " + type, "CAT")
135 
136 #----------------------------------------------------------------------------
137 
138 
def create(object, type)
Definition: shell.py:131

◆ data()

def shell.data (   object,
  stream = None 
)

Definition at line 150 of file shell.py.

Referenced by A3PE.clockDivision(), Server_NI6008.cmd(), SpecsMezzanine.cmdline(), Data.Data(), A3PE.enableStorage(), A3PE.fifoDepth(), A3PE.fifoLatency(), Register.getBit(), FePGA.i2cRead(), SeqPGA.i2cRead(), FePGA.i2cWrite(), SeqPGA.i2cWrite(), A3PE.latencyAX(), A3PE.lengthAX(), A3PE.loadFromAX(), A3PE.loadPattern(), A3PE.loadStorage(), A3PE.loadToAX(), A3PE.loadTrigger(), A3PE.nTrigger(), RAM.raz(), UsbFTMLInterface.read(), UsbFTInterface.read(), Register.setBit(), A3PE.setClockDivision(), LSDelayChipV1.setConfigReg(), Data.setData(), IOdata.setDataU16(), IOdata.setDataU32(), IOdata.setDataU8(), SeqPGA.setExtTrig(), A3PE.setFifoDepth(), A3PE.setFifoLatency(), FePGA.setI2cGBTSCA(), SeqPGA.setI2cGBTSCA(), SeqPGA.setLedEnable(), A3PE.setNTrigger(), A3PE.setPipeline(), SeqPGA.setSpiEnable(), SeqPGA.setSpiGBTSCA(), FePGA.setSpiGBTSCA(), A3PE.setTriggerDelay(), A3PE.setTriggerRate(), A3PE.triggerDelay(), A3PE.triggerRate(), UsbFTInterface.usbRead(), UsbFTMLInterface.usbRead(), UsbFTInterface.usbWrite(), UsbFTMLInterface.usbWrite(), UsbFTMLInterface.write(), SpecsInterface.write(), and UsbFTInterface.write().

150 def data(object, stream=None):
151  ok = False
152  list = cat.procDb().list()
153  for p in range(len(list)):
154  if (list[p].name() == object):
155  ok = True
156  if (stream == None):
157  list[p].data().info()
158  else:
159  return list[p].data().vector(stream)
160  if (ok == False):
161  cat.warning("Could not find processus " + object + ".", "CAT")
162  return
163 
164 #----------------------------------------------------------------------------
165 # application settings
166 
167 
def data(object, stream=None)
Definition: shell.py:150

◆ delete()

def shell.delete (   path = '')

Definition at line 181 of file shell.py.

References clear().

181 def delete(path=''):
182  if path == '*':
183  cat.current().clear()
184  else:
185  cat.current().delChild(path)
186 
187 
def delete(path='')
Definition: shell.py:181
def clear(path='')
Definition: shell.py:172

◆ get()

def shell.get (   path)

Definition at line 30 of file shell.py.

Referenced by run().

30 def get(path):
31  return cat.current().child(path)
32 
33 
def get(path)
Definition: shell.py:30

◆ init()

def shell.init ( )

Definition at line 203 of file shell.py.

Referenced by AppFrame.AppFrame.onInit().

203 def init():
204  cat.computer().recursiveInitCommunications()
205  cat.computer().recursiveInitElement()
206 
207 
def init()
Definition: shell.py:203

◆ ll()

def shell.ll (   path = '')

Definition at line 70 of file shell.py.

70 def ll(path=''):
71  if path == '':
72  element = cat.current()
73  else:
74  element = cat.current().child(path)
75  if type(element) != None:
76  lproc = cat.procDb().list(element)
77  nproc = len(lproc)
78  if (nproc) > 0:
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()
84  if (len(l)) > 0:
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")
95 
96 
def ll(path='')
Definition: shell.py:70

◆ load()

def shell.load (   filename)

Definition at line 39 of file shell.py.

References prompt().

Referenced by loadDll(), and reload().

39 def load(filename):
40  if (os.path.exists(filename) == False):
41  filename = filename + ".py"
42  if (os.path.exists(filename)):
43  execfile(filename)
44  prompt()
45  cat.options().setDefFile(filename)
46  else:
47  cat.warning("File " + filename + " does not exist.", "CAT")
48 
49 
def prompt()
Definition: shell.py:221
def load(filename)
Definition: shell.py:39

◆ loadDll()

def shell.loadDll (   name)

Definition at line 230 of file shell.py.

References load().

230 def loadDll(name):
231  cat.dllMgr().load(name)
232 
233 #----------------------------------------------------------------------------
234 # processing
235 
236 
def loadDll(name)
Definition: shell.py:230
def load(filename)
Definition: shell.py:39

◆ ls()

def shell.ls (   path = '')

Definition at line 56 of file shell.py.

56 def ls(path=''):
57  if path == '':
58  element = cat.current()
59  else:
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")
68 
69 
def ls(path='')
Definition: shell.py:56

◆ network()

def shell.network ( )

Definition at line 208 of file shell.py.

Referenced by Application.status().

208 def network():
209  cat.fatal("Not implemented.", "CAT")
210 
211 
def network()
Definition: shell.py:208

◆ obj()

def shell.obj ( )

Definition at line 26 of file shell.py.

Referenced by Application.create().

26 def obj():
27  return cat.current()
28 
29 
def obj()
Definition: shell.py:26

◆ opts()

def shell.opts ( )

Definition at line 19 of file shell.py.

Referenced by run().

19 def opts():
20  return cat.options()
21 
22 #----------------------------------------------------------------------------
23 # tree/object navigation
24 
25 
def opts()
Definition: shell.py:19

◆ outputLevel()

def shell.outputLevel (   level = 'INFO')

Definition at line 188 of file shell.py.

Referenced by shell().

188 def outputLevel(level='INFO'):
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)
195  if outLevel != None:
196  cat.options().setLogOutputLevel(outLevel)
197  else:
198  cat.warning("Output Level should be 'VERBOSE', 'DEBUG', 'INFO', 'WARNING' or 'FATAL'",
199  "CAT")
200  cat.warning("'" + level + "' level output not understood.", "CAT")
201 
202 
def outputLevel(level='INFO')
Definition: shell.py:188

◆ process()

def shell.process (   object)

Definition at line 139 of file shell.py.

Referenced by Application.prepare().

139 def process(object):
140  ok = False
141  list = cat.procDb().list()
142  for p in range(len(list)):
143  if (list[p].name() == object):
144  return list[p]
145  if (ok == False):
146  cat.warning("Could not find processus " + object + ".", "CAT")
147  return None
148 
149 
def process(object)
Definition: shell.py:139

◆ prompt()

def shell.prompt ( )

Definition at line 221 of file shell.py.

Referenced by cd(), load(), and shell().

221 def prompt():
222  current = cat.current()
223  if current != None:
224  sys.ps1 = "\033[92m" + current.name() + "\033[0m[\033[93m" + \
225  current.type() + "\033[0m] > "
226  else:
227  sys.ps1 = "\033[91mInvalid\033[0m[\033[95mNone\033[0m] > "
228 
229 
def prompt()
Definition: shell.py:221

◆ pwd()

def shell.pwd ( )

Definition at line 97 of file shell.py.

97 def pwd():
98  cat.info(cat.current().name() + " [" + cat.current().type() + "]", "CAT")
99 
100 
def pwd()
Definition: shell.py:97

◆ reload()

def shell.reload ( )

Definition at line 50 of file shell.py.

References clear(), and load().

Referenced by AppFrame.AppFrame.onReLoad().

50 def reload():
51  filename = cat.options().defFile()
52  cat.computer().clear()
53  load(filename)
54 
55 
def clear(path='')
Definition: shell.py:172
def reload()
Definition: shell.py:50
def load(filename)
Definition: shell.py:39

◆ reset()

def shell.reset (   path = '')

Definition at line 212 of file shell.py.

Referenced by BOOST_PYTHON_MODULE(), MSOxxxx.init(), ICECALv3.init(), LSDelayChipV1.init(), and ProtoFEB_v1.ProtoFEB_v1.onGlobalReset().

212 def reset(path=''):
213  if path == '':
214  element = cat.current()
215  else:
216  element = cat.current().child(path)
217  if type(element) != None:
218  element.reset()
219 
220 
def reset(path='')
Definition: shell.py:212

◆ run()

def shell.run (   processus,
  element,
  nevt 
)

Definition at line 237 of file shell.py.

References get(), and opts().

Referenced by Run.Run(), MSOxxxx.setDebugMode(), and Run.setNumber().

237 def run(processus, element, nevt):
238  if (type(element) == str):
239  element = get(element)
240  if (element == None):
241  return Code.FAILURE
242  ok = False
243  proc = None
244  list = cat.procDb().list(element)
245  for p in range(len(list)):
246  if (list[p].name() == processus):
247  proc = list[p]
248  ok = True
249  if (ok == False):
250  cat.warning("Could not find processus " + processus + ".", "CAT")
251  return Code.FAILURE
252  nrun = opts().runNumber()
253  if (cat.prepare(processus, element, nevt).isFailure()):
254  cat.warning("Could not prepare the processus " +
255  processus + ".", "CAT")
256  return Code.FAILURE
257  evt = nevt
258  width = 50
259 
260  plts = None
261  module = None
262  wrap = wrapper(cat, proc, "proc")
263  online = cat.options().plotFreq()
264  if (wrap.ok):
265  module = wrap.GetActive()
266  proc.setElement(element)
267  if module and (online != 0):
268  plts = module.createPlots(cat, proc, nrun)
269 
271  processus, end=abs(evt), width=width, fill='▣', blank='-')
272  timing = -1.
273  ievt = 0
274  if (evt<0): timing = time.time()
275  evt = abs(evt)
276  stop = False
277 
278  try:
279  while ( not stop ):
280  ievt+=1
281  if timing>=0:
282  elapsed = time.time() - timing
283  p.set(elapsed)
284  if elapsed > evt : stop = True
285  else :
286  p + 1
287  if ievt>=evt : stop = True
288  p.show_progress()
289  if (cat.loop().isFailure()):
290  cat.warning("Error detected during processing.", "CAT")
291  if online>0 and plt:
292  if ievt%online==0:
293  if module :
294  module.updatePlots(plts, proc)
295  except KeyboardInterrupt:
296  pass
297 
298  cat.terminate()
299  if module and online==0:
300  plts = module.createPlots(cat, proc, nrun)
301  module.updatePlots(plts, proc)
302 
303  # Plot(processus, nrun)
304 
305 # def plot(processus, nrun):
306 # p = proc(processus)
307 # if (p != None):
308 # wrap = wrapper(cat, p, "proc")
309 # if (wrap.ok):
310 # module = wrap.GetActive()
311 # plot = module.Plot(cat, p, None, nrun)
312 # if plot:
313 # plot.current().show()
314 # return Code.SUCCESS
315 
316 # def finalplot(processus, nrun):
317 # p = proc(processus)
318 # if (p != None):
319 # wrap = wrapper(cat, p, "proc")
320 # if (wrap.ok):
321 # module = wrap.GetActive()
322 # plot = module.FinalPlot(cat, p, None, nrun)
323 # if plot:
324 # plot.current().show()
325 # return Code.SUCCESS
326 
327 
def get(path)
Definition: shell.py:30
def run(processus, element, nevt)
Definition: shell.py:237
def opts()
Definition: shell.py:19

◆ shell()

def shell.shell (   app,
  args 
)

Definition at line 328 of file shell.py.

References outputLevel(), and prompt().

328 def shell(app, args):
329  import version
330  global cat
331  global figid
332  figid = 0
333  if (app == None):
334  cat = Application()
335  else:
336  cat = app
337  outputLevel(args.output)
338  vers = version.version()
339  vers.info()
340  cat.initialize()
341  if ("" <> args.file):
342  if (os.path.exists(args.file)):
343  execfile(args.file)
344  cat.options().setDefFile(args.file)
345  else:
346  cat.fatal("Cannot execute init file " +
347  args.file + ". Abort.", "CAT")
348  return -1
349  prompt()
350 
351 # main
352 
def prompt()
Definition: shell.py:221
def outputLevel(level='INFO')
Definition: shell.py:188
def shell(app, args)
Definition: shell.py:328

◆ tree()

def shell.tree (   path = '')

Definition at line 101 of file shell.py.

101 def tree(path=''):
102  if path == '':
103  element = cat.current()
104  else:
105  element = cat.current().child(path)
106  if type(element) != None:
107  element.tree()
108 
109 
def tree(path='')
Definition: shell.py:101

◆ view()

def shell.view (   path = '',
  indent = '  ' 
)

Definition at line 110 of file shell.py.

110 def view(path='', indent=' '):
111  if path == '':
112  element = cat.current()
113  else:
114  element = cat.current().child(path)
115  line = indent + ' -> ' + \
116  element.name() + '[' + element.type() + \
117  ' - ' + element.attributs() + ']'
118  print line
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 + ' ')
125 
126  # def com(objecgt):
127  # while connection!=None:
128  # print connection()
129 
130 
def view(path='', indent=' ')
Definition: shell.py:110

Variable Documentation

◆ args

shell.args = arguments()

Definition at line 354 of file shell.py.

◆ shellMode

shell.shellMode

Definition at line 355 of file shell.py.