All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
gaudirun Namespace Reference

Classes

class  FakeModule
 

Functions

def getArgsWithoutoProfilerInfo
 
def rationalizepath
 
def getArgsFromQmt
 
def option_cb
 

Variables

list _qmt_tmp_opt_files []
 
tuple parser OptionParser(usage = "%prog [options] <opts_file> ...")
 
string help "do not run the application, just parse option files"
 
string metavar "FILE"
 
string type "string"
 
string dest "old_conf_user_apply"
 
 tcmalloc False,
 
string profilerName ''
 
string profilerOutput ''
 
string profilerExtraOptions ''
 
list preload []
 
 ncpus None,
 
string old_conf_user_apply 'GAUDI_FIXED_APPLY_CONF'
 
list argv []
 
tuple sys_cpus cpu_count()
 
string s "Invalid value : --ncpus : only %i cpus available"
 
 level logging.INFO
 
tuple root_logger logging.getLogger()
 
list to_load
 
list args [ a for a in sys.argv if a != '-T' and not '--tcmalloc'.startswith(a) ]
 
string profilerExecName ""
 
string igprofPerfOptions "-d -pp -z -o igprof.pp.gz"
 
string profilerOptions ""
 
tuple toolname profilerName.replace('valgrind','')
 
string outoption "--log-file"
 
tuple profilerPath distutils.spawn.find_executable(profilerExecName)
 
list arglist [profilerPath]
 
tuple c gaudimain()
 
list options [ "importOptions(%r)" % f for f in args ]
 
tuple optlines list(opts.options)
 
dictionary g {}
 
dictionary l {}
 

Function Documentation

def gaudirun.getArgsFromQmt (   qmtfile)
Given a .qmt file, return the command line arguments of the corresponding
test.

Definition at line 47 of file gaudirun.py.

47 
48 def getArgsFromQmt(qmtfile):
49  '''
50  Given a .qmt file, return the command line arguments of the corresponding
51  test.
52  '''
53  from xml.etree import ElementTree as ET
54  global _qmt_tmp_opt_files
55  # parse the .qmt file and extract args and options
56  qmt = ET.parse(qmtfile)
57  args = [a.text for a in qmt.findall("argument[@name='args']//text")]
58  options = qmt.find("argument[@name='options']/text")
59 
60  if options is not None: # options need to be dumped in a temporary file
61  from tempfile import NamedTemporaryFile
62  import re
63  if re.search(r"from\s+Gaudi.Configuration\s+import\s+\*"
64  r"|from\s+Configurables\s+import", options.text):
65  tmp_opts = NamedTemporaryFile(suffix='.py')
66  else:
67  tmp_opts = NamedTemporaryFile(suffix='.opts')
68  tmp_opts.write(options.text)
69  tmp_opts.flush()
70  args.append(tmp_opts.name)
71  _qmt_tmp_opt_files.append(tmp_opts)
72 
73  # relative paths in a .qmt are rooted in the qmtest directory, so
74  # - find where the .qmt lives
75  qmtfile = os.path.abspath(qmtfile)
76  if 'qmtest' in qmtfile.split(os.path.sep):
77  # this return the path up to the 'qmtest' entry in qmtfile
78  testdir = qmtfile
79  while os.path.basename(testdir) != 'qmtest':
80  testdir = os.path.dirname(testdir)
81  else:
82  testdir = '.'
83  # - temporarily switch to that directory and rationalize the paths
84  old_cwd = os.getcwd()
85  os.chdir(testdir)
86  args = map(rationalizepath, args)
87  os.chdir(old_cwd)
88 
89  return args
90 
#---------------------------------------------------------------------
def gaudirun.getArgsWithoutoProfilerInfo (   args)
Remove from the arguments the presence of the profiler and its output in
order to relaunch the script w/o infinite loops.

>>> getArgsWithoutoProfilerInfo(['--profilerName', 'igprof', 'myopts.py'])
['myopts.py']

>>> getArgsWithoutoProfilerInfo(['--profilerName=igprof', 'myopts.py'])
['myopts.py']

>>> getArgsWithoutoProfilerInfo(['--profilerName', 'igprof', '--profilerExtraOptions', 'a b c', 'myopts.py'])
['myopts.py']

>>> getArgsWithoutoProfilerInfo(['--profilerName', 'igprof', '--options', 'a b c', 'myopts.py'])
['--options', 'a b c', 'myopts.py']

Definition at line 7 of file gaudirun.py.

7 
9  """
10  Remove from the arguments the presence of the profiler and its output in
11  order to relaunch the script w/o infinite loops.
12 
13  >>> getArgsWithoutoProfilerInfo(['--profilerName', 'igprof', 'myopts.py'])
14  ['myopts.py']
15 
16  >>> getArgsWithoutoProfilerInfo(['--profilerName=igprof', 'myopts.py'])
17  ['myopts.py']
18 
19  >>> getArgsWithoutoProfilerInfo(['--profilerName', 'igprof', '--profilerExtraOptions', 'a b c', 'myopts.py'])
20  ['myopts.py']
21 
22  >>> getArgsWithoutoProfilerInfo(['--profilerName', 'igprof', '--options', 'a b c', 'myopts.py'])
23  ['--options', 'a b c', 'myopts.py']
24  """
25  newargs = []
26  args = list(args) # make a temp copy
27  while args:
28  o = args.pop(0)
29  if o.startswith('--profile'):
30  if '=' not in o:
31  args.pop(0)
32  else:
33  newargs.append(o)
34  return newargs
def gaudirun.option_cb (   option,
  opt,
  value,
  parser 
)
Add the option line to a list together with its position in the
argument list.

Definition at line 121 of file gaudirun.py.

122  def option_cb(option, opt, value, parser):
123  """Add the option line to a list together with its position in the
124  argument list.
125  """
parser.values.options.append((len(parser.largs), value))
def gaudirun.rationalizepath (   path)
Convert the given path to a real path if the pointed file exists, otherwise
just normalize it.

Definition at line 35 of file gaudirun.py.

35 
36 def rationalizepath(path):
37  '''
38  Convert the given path to a real path if the pointed file exists, otherwise
39  just normalize it.
40  '''
41  path = os.path.normpath(os.path.expandvars(path))
42  if os.path.exists(path):
43  path = os.path.realpath(path)
44  return path
45 
# variable used to keep alive the temporary option files extracted from the .qmt

Variable Documentation

list gaudirun._qmt_tmp_opt_files []

Definition at line 46 of file gaudirun.py.

list gaudirun.arglist [profilerPath]

Definition at line 331 of file gaudirun.py.

tuple gaudirun.args [ a for a in sys.argv if a != '-T' and not '--tcmalloc'.startswith(a) ]

Definition at line 262 of file gaudirun.py.

list gaudirun.argv []

Definition at line 199 of file gaudirun.py.

tuple gaudirun.c gaudimain()

Definition at line 349 of file gaudirun.py.

string gaudirun.dest "old_conf_user_apply"

Definition at line 138 of file gaudirun.py.

dictionary gaudirun.g {}

Definition at line 378 of file gaudirun.py.

string gaudirun.help "do not run the application, just parse option files"

Definition at line 100 of file gaudirun.py.

string gaudirun.igprofPerfOptions "-d -pp -z -o igprof.pp.gz"

Definition at line 274 of file gaudirun.py.

dictionary gaudirun.l {}

Definition at line 379 of file gaudirun.py.

gaudirun.level logging.INFO

Definition at line 233 of file gaudirun.py.

string gaudirun.metavar "FILE"

Definition at line 102 of file gaudirun.py.

gaudirun.ncpus None,

Definition at line 194 of file gaudirun.py.

string gaudirun.old_conf_user_apply 'GAUDI_FIXED_APPLY_CONF'

Definition at line 196 of file gaudirun.py.

list gaudirun.options [ "importOptions(%r)" % f for f in args ]

Definition at line 354 of file gaudirun.py.

tuple gaudirun.optlines list(opts.options)

Definition at line 357 of file gaudirun.py.

string gaudirun.outoption "--log-file"

Definition at line 300 of file gaudirun.py.

tuple gaudirun.parser OptionParser(usage = "%prog [options] <opts_file> ...")

Definition at line 98 of file gaudirun.py.

string gaudirun.preload []

Definition at line 193 of file gaudirun.py.

string gaudirun.profilerExecName ""

Definition at line 268 of file gaudirun.py.

tuple gaudirun.profilerExtraOptions ''

Definition at line 192 of file gaudirun.py.

string gaudirun.profilerName ''

Definition at line 190 of file gaudirun.py.

string gaudirun.profilerOptions ""

Definition at line 276 of file gaudirun.py.

tuple gaudirun.profilerOutput ''

Definition at line 191 of file gaudirun.py.

tuple gaudirun.profilerPath distutils.spawn.find_executable(profilerExecName)

Definition at line 317 of file gaudirun.py.

tuple gaudirun.root_logger logging.getLogger()

Definition at line 237 of file gaudirun.py.

string gaudirun.s "Invalid value : --ncpus : only %i cpus available"

Definition at line 217 of file gaudirun.py.

tuple gaudirun.sys_cpus cpu_count()

Definition at line 215 of file gaudirun.py.

gaudirun.tcmalloc False,

Definition at line 189 of file gaudirun.py.

list gaudirun.to_load
Initial value:
1 [libname
2  for libname in opts.preload
3  if libname not in set(preload)]

Definition at line 252 of file gaudirun.py.

tuple gaudirun.toolname profilerName.replace('valgrind','')

Definition at line 299 of file gaudirun.py.

string gaudirun.type "string"

Definition at line 127 of file gaudirun.py.