gaudirun Namespace Reference

Classes

class  FakeModule
 

Functions

def getArgsWithoutoProfilerInfo (args)
 
def rationalizepath (path)
 
def getArgsFromQmt (qmtfile)
 
def option_cb (option, opt, value, parser)
 

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

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

121  def option_cb(option, opt, value, parser):
122  """Add the option line to a list together with its position in the
123  argument list.
124  """
125  parser.values.options.append((len(parser.largs), value))
def option_cb(option, opt, value, parser)
Definition: gaudirun.py:121
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 def rationalizepath(path):
36  '''
37  Convert the given path to a real path if the pointed file exists, otherwise
38  just normalize it.
39  '''
40  path = os.path.normpath(os.path.expandvars(path))
41  if os.path.exists(path):
42  path = os.path.realpath(path)
43  return path
44 
45 # variable used to keep alive the temporary option files extracted from the .qmt
def rationalizepath(path)
Definition: gaudirun.py:35

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.

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.