The Gaudi Framework  v30r3 (a5ef0a68)
gaudirun Namespace Reference

Classes

class  FakeModule
 

Functions

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

Variables

list _qmt_tmp_opt_files = []
 
 parser = OptionParser(usage="%prog [options] <opts_file> ...")
 
 action
 
 help
 
 type
 
 metavar
 
 default
 
 callback
 
 nargs
 
 dest
 
 options = ["importOptions(%r)" % f for f in args]
 
 tcmalloc
 
 profilerName = opts.profilerName
 
 profilerOutput = opts.profilerOutputor(profilerName + ".output")
 
 profilerExtraOptions = opts.profilerExtraOptions
 
 preload = os.environ.get("LD_PRELOAD", "")
 
 ncpus
 
 old_conf_user_apply
 
 run_info_file
 
list argv = []
 
 opts
 
 args
 
 sys_cpus = cpu_count()
 
string s = "Invalid value : --ncpus : only %i cpus available"
 
string prefix = "// "
 
 level = logging.INFO
 
 with_time
 
 root_logger = logging.getLogger()
 
list to_load
 
string profilerExecName = ""
 
string igprofPerfOptions = "-d -pp -z -o igprof.pp.gz"
 
string profilerOptions = ""
 
 toolname = profilerName.replace('valgrind', '')
 
string outoption = "--log-file"
 
 profilerPath = distutils.spawn.find_executable(profilerExecName)
 
list to_reload = []
 
list arglist = [profilerPath]+profilerOptions.split()+args
 
 output
 
 c = gaudimain()
 
 optlines = list(opts.options)
 
dictionary g = {}
 
dictionary l = {}
 
 _appliedConfigurableUsers_
 
 use_temp_opts
 
 fd
 
 tmpfile
 
 printsequence
 
 retcode = c.run(opts.gdb, opts.ncpus)
 
dictionary run_info = {}
 

Function Documentation

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

Definition at line 78 of file gaudirun.py.

78 def getArgsFromQmt(qmtfile):
79  '''
80  Given a .qmt file, return the command line arguments of the corresponding
81  test.
82  '''
83  from xml.etree import ElementTree as ET
84  global _qmt_tmp_opt_files
85  # parse the .qmt file and extract args and options
86  qmt = ET.parse(qmtfile)
87  args = [a.text for a in qmt.findall("argument[@name='args']//text")]
88  options = qmt.find("argument[@name='options']/text")
89 
90  if options is not None: # options need to be dumped in a temporary file
91  from tempfile import NamedTemporaryFile
92  import re
93  if re.search(r"from\s+Gaudi.Configuration\s+import\s+\*"
94  r"|from\s+Configurables\s+import", options.text):
95  tmp_opts = NamedTemporaryFile(suffix='.py')
96  else:
97  tmp_opts = NamedTemporaryFile(suffix='.opts')
98  tmp_opts.write(options.text)
99  tmp_opts.flush()
100  args.append(tmp_opts.name)
101  _qmt_tmp_opt_files.append(tmp_opts)
102 
103  # relative paths in a .qmt are rooted in the qmtest directory, so
104  # - find where the .qmt lives
105  qmtfile = os.path.abspath(qmtfile)
106  if 'qmtest' in qmtfile.split(os.path.sep):
107  # this return the path up to the 'qmtest' entry in qmtfile
108  testdir = qmtfile
109  while os.path.basename(testdir) != 'qmtest':
110  testdir = os.path.dirname(testdir)
111  else:
112  testdir = '.'
113  # - temporarily switch to that directory and rationalize the paths
114  old_cwd = os.getcwd()
115  os.chdir(testdir)
116  args = map(rationalizepath, args)
117  os.chdir(old_cwd)
118 
119  return args
120 
121 
122 # ---------------------------------------------------------------------
def getArgsFromQmt(qmtfile)
Definition: gaudirun.py:78
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 8 of file gaudirun.py.

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
35 
36 
def getArgsWithoutoProfilerInfo(args)
Definition: gaudirun.py:8
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 153 of file gaudirun.py.

153  def option_cb(option, opt, value, parser):
154  """Add the option line to a list together with its position in the
155  argument list.
156  """
157  parser.values.options.append((len(parser.largs), value))
def option_cb(option, opt, value, parser)
Definition: gaudirun.py:153
def gaudirun.rationalizepath (   path)
Convert the given path to a real path if the pointed file exists, otherwise
just normalize it.

Definition at line 62 of file gaudirun.py.

62 def rationalizepath(path):
63  '''
64  Convert the given path to a real path if the pointed file exists, otherwise
65  just normalize it.
66  '''
67  path = os.path.normpath(os.path.expandvars(path))
68  if os.path.exists(path):
69  path = os.path.realpath(path)
70  return path
71 
72 
73 # variable used to keep alive the temporary option files extracted
74 # from the .qmt
def rationalizepath(path)
Definition: gaudirun.py:62
def gaudirun.setLibraryPreload (   newpreload)
Adds  a list of libraries to LD_PRELOAD 

Definition at line 37 of file gaudirun.py.

37 def setLibraryPreload(newpreload):
38  ''' Adds a list of libraries to LD_PRELOAD '''
39  preload = os.environ.get("LD_PRELOAD", "")
40  if preload:
41  preload = preload.replace(" ", ":").split(":")
42  else:
43  preload = []
44 
45  for libname in set(preload).intersection(newpreload):
46  logging.warning("Ignoring preload of library %s because it is "
47  "already in LD_PRELOAD.", libname)
48 
49  to_load = [libname
50  for libname in newpreload
51  if libname not in set(preload)]
52 
53  if to_load:
54  preload += to_load
55  preload = ":".join(preload)
56  os.environ["LD_PRELOAD"] = preload
57  logging.info("Setting LD_PRELOAD='%s'", preload)
58 
59  return to_load
60 
61 
def setLibraryPreload(newpreload)
Definition: gaudirun.py:37

Variable Documentation

gaudirun._appliedConfigurableUsers_
private

Definition at line 450 of file gaudirun.py.

list gaudirun._qmt_tmp_opt_files = []
private

Definition at line 75 of file gaudirun.py.

gaudirun.action

Definition at line 131 of file gaudirun.py.

list gaudirun.arglist = [profilerPath]+profilerOptions.split()+args

Definition at line 384 of file gaudirun.py.

list gaudirun.args
Initial value:
1 = [a for a in sys.argv if a !=
2  '-T' and not '--tcmalloc'.startswith(a)]

Definition at line 244 of file gaudirun.py.

list gaudirun.argv = []

Definition at line 235 of file gaudirun.py.

gaudirun.c = gaudimain()

Definition at line 407 of file gaudirun.py.

gaudirun.callback

Definition at line 158 of file gaudirun.py.

gaudirun.default

Definition at line 149 of file gaudirun.py.

gaudirun.dest

Definition at line 170 of file gaudirun.py.

gaudirun.fd

Definition at line 478 of file gaudirun.py.

dictionary gaudirun.g = {}

Definition at line 439 of file gaudirun.py.

gaudirun.help

Definition at line 132 of file gaudirun.py.

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

Definition at line 313 of file gaudirun.py.

dictionary gaudirun.l = {}

Definition at line 440 of file gaudirun.py.

gaudirun.level = logging.INFO

Definition at line 271 of file gaudirun.py.

gaudirun.metavar

Definition at line 134 of file gaudirun.py.

gaudirun.nargs

Definition at line 159 of file gaudirun.py.

gaudirun.ncpus

Definition at line 229 of file gaudirun.py.

gaudirun.old_conf_user_apply

Definition at line 231 of file gaudirun.py.

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

Definition at line 223 of file gaudirun.py.

gaudirun.optlines = list(opts.options)

Definition at line 415 of file gaudirun.py.

gaudirun.opts

Definition at line 244 of file gaudirun.py.

string gaudirun.outoption = "--log-file"

Definition at line 339 of file gaudirun.py.

gaudirun.output

Definition at line 404 of file gaudirun.py.

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

Definition at line 130 of file gaudirun.py.

string gaudirun.prefix = "// "

Definition at line 268 of file gaudirun.py.

string gaudirun.preload = os.environ.get("LD_PRELOAD", "")

Definition at line 228 of file gaudirun.py.

gaudirun.printsequence

Definition at line 485 of file gaudirun.py.

string gaudirun.profilerExecName = ""

Definition at line 307 of file gaudirun.py.

gaudirun.profilerExtraOptions = opts.profilerExtraOptions

Definition at line 227 of file gaudirun.py.

gaudirun.profilerName = opts.profilerName

Definition at line 225 of file gaudirun.py.

string gaudirun.profilerOptions = ""

Definition at line 315 of file gaudirun.py.

gaudirun.profilerOutput = opts.profilerOutputor(profilerName + ".output")

Definition at line 226 of file gaudirun.py.

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

Definition at line 362 of file gaudirun.py.

gaudirun.retcode = c.run(opts.gdb, opts.ncpus)

Definition at line 499 of file gaudirun.py.

gaudirun.root_logger = logging.getLogger()

Definition at line 275 of file gaudirun.py.

dictionary gaudirun.run_info = {}

Definition at line 506 of file gaudirun.py.

gaudirun.run_info_file

Definition at line 232 of file gaudirun.py.

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

Definition at line 253 of file gaudirun.py.

gaudirun.sys_cpus = cpu_count()

Definition at line 251 of file gaudirun.py.

gaudirun.tcmalloc

Definition at line 224 of file gaudirun.py.

gaudirun.tmpfile

Definition at line 478 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 290 of file gaudirun.py.

gaudirun.to_reload = []

Definition at line 375 of file gaudirun.py.

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

Definition at line 338 of file gaudirun.py.

gaudirun.type

Definition at line 133 of file gaudirun.py.

gaudirun.use_temp_opts

Definition at line 470 of file gaudirun.py.

gaudirun.with_time

Definition at line 274 of file gaudirun.py.