| The Gaudi Framework v32r1 (f65d50dc)

Classes | Functions | Variables
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.profilerOutput or (profilerName + ".output")
| profilerExtraOptions = opts.profilerExtraOptions
| preload = os.environ.get("LD_PRELOAD", "")
| ncpus
| old_conf_user_apply
| run_info_file
| application
list | argv = []
| opts
| args
| sys_cpus = cpu_count()
string | s = "Invalid value : --ncpus : only %i cpus available" % sys_cpus
string | prefix = "// "
| level = logging.INFO
| with_time
| root_logger = logging.getLogger()
| sanitizer = os.environ.get("PRELOAD_SANITIZER_LIB", "")
list | to_load
string | profilerExecName = ""
string | igprofPerfOptions = "-d -pp -z -o igprof.pp.gz".split()
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

## ◆ getArgsFromQmt()

def gaudirun.getArgsFromQmt | ( |  | qmtfile | ) |

    Given a .qmt file, return the command line arguments of the corresponding
    test.

Definition at line 79 of file gaudirun.py.

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

## ◆ getArgsWithoutoProfilerInfo()

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.

8 def getArgsWithoutoProfilerInfo(args):
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
gaudirun.getArgsWithoutoProfilerInfo
def getArgsWithoutoProfilerInfo(args)
Definition: gaudirun.py:8

## ◆ option_cb()

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 173 of file gaudirun.py.

173 def option_cb(option, opt, value, parser):
174 """Add the option line to a list together with its position in the
175 argument list.
176 """
177 parser.values.options.append((len(parser.largs), value))
178
gaudirun.option_cb
def option_cb(option, opt, value, parser)
Definition: gaudirun.py:173

## ◆ rationalizepath()

def gaudirun.rationalizepath | ( |  | path | ) |

    Convert the given path to a real path if the pointed file exists, otherwise
    just normalize it.

Definition at line 63 of file gaudirun.py.

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

## ◆ setLibraryPreload()

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(
47 "Ignoring preload of library %s because it is "
48 "already in LD_PRELOAD.", libname)
49
50 to_load = [
51 libname for libname in newpreload if libname not in set(preload)
52 ]
53
54 if to_load:
55 preload += to_load
56 preload = ":".join(preload)
57 os.environ["LD_PRELOAD"] = preload
58 logging.info("Setting LD_PRELOAD='%s'", preload)
59
60 return to_load
61
62
gaudirun.setLibraryPreload
def setLibraryPreload(newpreload)
Definition: gaudirun.py:37

## Variable Documentation

## ◆ _appliedConfigurableUsers_

gaudirun._appliedConfigurableUsers_
| private

Definition at line 531 of file gaudirun.py.

## ◆ _qmt_tmp_opt_files

list gaudirun._qmt_tmp_opt_files = []
| private

Definition at line 76 of file gaudirun.py.

## ◆ action

gaudirun.action

Definition at line 136 of file gaudirun.py.

## ◆ application

gaudirun.application

Definition at line 295 of file gaudirun.py.

## ◆ arglist

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

Definition at line 464 of file gaudirun.py.

## ◆ args

def gaudirun.args

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

Definition at line 307 of file gaudirun.py.

## ◆ argv

list gaudirun.argv = []

Definition at line 298 of file gaudirun.py.

## ◆ c

gaudirun.c = gaudimain()

Definition at line 487 of file gaudirun.py.

## ◆ callback

gaudirun.callback

Definition at line 182 of file gaudirun.py.

## ◆ default

gaudirun.default

Definition at line 169 of file gaudirun.py.

## ◆ dest

gaudirun.dest

Definition at line 201 of file gaudirun.py.

## ◆ fd

gaudirun.fd

Definition at line 559 of file gaudirun.py.

## ◆ g

dictionary gaudirun.g = {}

Definition at line 520 of file gaudirun.py.

## ◆ help

gaudirun.help

Definition at line 137 of file gaudirun.py.

## ◆ igprofPerfOptions

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

Definition at line 392 of file gaudirun.py.

## ◆ l

dictionary gaudirun.l = {}

Definition at line 521 of file gaudirun.py.

## ◆ level

gaudirun.level = logging.INFO

Definition at line 334 of file gaudirun.py.

## ◆ metavar

gaudirun.metavar

Definition at line 143 of file gaudirun.py.

## ◆ nargs

gaudirun.nargs

Definition at line 184 of file gaudirun.py.

## ◆ ncpus

gaudirun.ncpus

Definition at line 291 of file gaudirun.py.

## ◆ old_conf_user_apply

gaudirun.old_conf_user_apply

Definition at line 293 of file gaudirun.py.

## ◆ options

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

Definition at line 285 of file gaudirun.py.

## ◆ optlines

gaudirun.optlines = list(opts.options)

Definition at line 495 of file gaudirun.py.

## ◆ opts

gaudirun.opts

Definition at line 307 of file gaudirun.py.

## ◆ outoption

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

Definition at line 418 of file gaudirun.py.

## ◆ output

gaudirun.output

Definition at line 484 of file gaudirun.py.

## ◆ parser

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

Definition at line 132 of file gaudirun.py.

## ◆ prefix

string gaudirun.prefix = "// "

Definition at line 331 of file gaudirun.py.

## ◆ preload

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

Definition at line 290 of file gaudirun.py.

## ◆ printsequence

gaudirun.printsequence

Definition at line 566 of file gaudirun.py.

## ◆ profilerExecName

string gaudirun.profilerExecName = ""

Definition at line 386 of file gaudirun.py.

## ◆ profilerExtraOptions

gaudirun.profilerExtraOptions = opts.profilerExtraOptions

Definition at line 289 of file gaudirun.py.

## ◆ profilerName

gaudirun.profilerName = opts.profilerName

Definition at line 287 of file gaudirun.py.

## ◆ profilerOptions

string gaudirun.profilerOptions = ""

Definition at line 394 of file gaudirun.py.

## ◆ profilerOutput

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

Definition at line 288 of file gaudirun.py.

## ◆ profilerPath

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

Definition at line 441 of file gaudirun.py.

## ◆ retcode

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

Definition at line 582 of file gaudirun.py.

## ◆ root_logger

gaudirun.root_logger = logging.getLogger()

Definition at line 338 of file gaudirun.py.

## ◆ run_info

dictionary gaudirun.run_info = {}

Definition at line 589 of file gaudirun.py.

## ◆ run_info_file

gaudirun.run_info_file

Definition at line 294 of file gaudirun.py.

## ◆ s

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

Definition at line 316 of file gaudirun.py.

## ◆ sanitizer

gaudirun.sanitizer = os.environ.get("PRELOAD_SANITIZER_LIB", "")

Definition at line 341 of file gaudirun.py.

## ◆ sys_cpus

gaudirun.sys_cpus = cpu_count()

Definition at line 314 of file gaudirun.py.

## ◆ tcmalloc

gaudirun.tcmalloc

Definition at line 286 of file gaudirun.py.

## ◆ tmpfile

gaudirun.tmpfile

Definition at line 559 of file gaudirun.py.

## ◆ to_load

list gaudirun.to_load

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

Definition at line 367 of file gaudirun.py.

## ◆ to_reload

def gaudirun.to_reload = []

Definition at line 455 of file gaudirun.py.

## ◆ toolname

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

Definition at line 417 of file gaudirun.py.

## ◆ type

gaudirun.type

Definition at line 142 of file gaudirun.py.

## ◆ use_temp_opts

gaudirun.use_temp_opts

Definition at line 551 of file gaudirun.py.

## ◆ with_time

gaudirun.with_time

Definition at line 337 of file gaudirun.py.