summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Clemencic <marco.clemencic@cern.ch>2013-02-15 15:46:30 +0000
committerMarco Clemencic <marco.clemencic@cern.ch>2013-02-15 15:46:30 +0000
commit34d79fedf53422a915729f48e95385fcddc82fa5 (patch)
tree04ee1bd8472ed0310087af676be6903093739ecb
parent13dff655b0d046edd1dee9281ebc26dacb1da980 (diff)
minor changes and a fix to patch #5605
There was a minor bug in the new function and some minor style issues. https://savannah.cern.ch/patch/?5605 From: Marco Clemencic <marco.clemencic@cern.ch> git-svn-id: svn+ssh://svn.cern.ch/reps/gaudi/Gaudi/trunk@7126 53ecefc3-a64d-0410-9bdf-b8581fa3287e
-rw-r--r--Gaudi/doc/release.notes3
-rwxr-xr-xGaudi/scripts/gaudirun.py118
2 files changed, 64 insertions, 57 deletions
diff --git a/Gaudi/doc/release.notes b/Gaudi/doc/release.notes
index 23d7524..df9d23f 100644
--- a/Gaudi/doc/release.notes
+++ b/Gaudi/doc/release.notes
@@ -13,7 +13,8 @@ Package manager : Marco Clemencic
options are added (compress output, be verbose)
o --profilerOutput: Specify the output file name. If not selected, a default
is provided.
- o --profilerExtraOptions: specify extra options for the profiler.
+ o --profilerExtraOptions: specify extra options for the profiler, where the
+ '--' is replaces with a '__'.
================================ Gaudi v23r6 =================================
================================ Gaudi v23r5 =================================
diff --git a/Gaudi/scripts/gaudirun.py b/Gaudi/scripts/gaudirun.py
index 772d187..53e8095 100755
--- a/Gaudi/scripts/gaudirun.py
+++ b/Gaudi/scripts/gaudirun.py
@@ -1,25 +1,32 @@
#!/usr/bin/env python
-def getArgsWithoutoProfilerInfo(args,profilerName,outputName,extraOptions):
- """
- Remove from the arguments the presence of the profiler and its output in
- order to relaunch the script w/o infinite loops.
- """
- import re
- args_string=""
- for arg in args: args_string+="%s " %arg
- args_string=args_string[:-1]
-
- # replace the occurrence of the profiler
- args_string = re.sub("--profilerName\s*(=)?\s*%s"%profilerName,"",args_string)
-
- # replace the occurrence of the outputname
- args_string = re.sub("--profilerOutput\s*(=)?\s*%s"%outputName,"",args_string)
-
- # replace the extra options
- args_string = re.sub("--profilerExtraOptions\s*(=)?\s*%s"%extraOptions,"",args_string)
-
- return args_string.split()
+def 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']
+ """
+ newargs = []
+ args = list(args) # make a temp copy
+ while args:
+ o = args.pop(0)
+ if o.startswith('--profile'):
+ if '=' not in o:
+ args.pop(0)
+ else:
+ newargs.append(o)
+ return newargs
#---------------------------------------------------------------------
@@ -166,73 +173,72 @@ if __name__ == "__main__":
os.execv(sys.executable, [sys.executable] + args)
# Profiler Support ------
- if opts.profilerName != "":
+ if opts.profilerName:
profilerName = opts.profilerName
- profilerExecName=""
- profilerOutput= opts.profilerOutput
- if opts.profilerOutput == "":
- profilerOutput = profilerName+".output"
+ profilerExecName = ""
+ profilerOutput = opts.profilerOutput or (profilerName + ".output")
# To restart the application removing the igprof option and prepending the string
- args = getArgsWithoutoProfilerInfo(sys.argv,
- profilerName,
- opts.profilerOutput,
- opts.profilerExtraOptions)
+ args = getArgsWithoutoProfilerInfo(sys.argv)
igprofPerfOptions = "-d -pp -z -o igprof.pp.gz".split()
profilerOptions = ""
if profilerName == "igprof":
- if opts.profilerOutput == "":
- profilerOutput += ".profile.gz"
- profilerOptions = "-d -z -o %s" %profilerOutput
- profilerExecName="igprof"
+ if not opts.profilerOutput:
+ profilerOutput += ".profile.gz"
+ profilerOptions = "-d -z -o %s" % profilerOutput
+ profilerExecName = "igprof"
+
elif profilerName == "igprofPerf":
- if opts.profilerOutput == "":
- profilerOutput += ".pp.gz"
- profilerOptions = "-d -pp -z -o %s" %profilerOutput
- profilerExecName="igprof"
+ if not opts.profilerOutput:
+ profilerOutput += ".pp.gz"
+ profilerOptions = "-d -pp -z -o %s" % profilerOutput
+ profilerExecName = "igprof"
+
elif profilerName == "igprofMem":
- if opts.profilerOutput == "":
- profilerOutput += ".mp.gz"
- profilerOptions = "-d -mp -z -o %s" %profilerOutput
- profilerExecName="igprof"
+ if not opts.profilerOutput:
+ profilerOutput += ".mp.gz"
+ profilerOptions = "-d -mp -z -o %s" % profilerOutput
+ profilerExecName = "igprof"
+
elif "valgrind" in profilerName:
# extract the tool
- if opts.profilerOutput == "":
- profilerOutput += ".log"
- toolname=profilerName.replace('valgrind','')
- outoption="--log-file"
- if toolname in ("massif","callgrind","cachegrind"):
- outoption="--%s-out-file" %toolname
- profilerOptions = "--tool=%s %s=%s" %(toolname,outoption,profilerOutput)
- profilerExecName="valgrind"
+ if not opts.profilerOutput:
+ profilerOutput += ".log"
+ toolname = profilerName.replace('valgrind','')
+ outoption = "--log-file"
+ if toolname in ("massif", "callgrind", "cachegrind"):
+ outoption = "--%s-out-file" % toolname
+ profilerOptions = "--tool=%s %s=%s" % (toolname, outoption, profilerOutput)
+ profilerExecName = "valgrind"
+
else:
- root_logger.warning("Profiler %s not recognised!" %profilerName)
+ root_logger.warning("Profiler %s not recognized!" % profilerName)
# Add potential extra options
if opts.profilerExtraOptions!="":
profilerExtraOptions = opts.profilerExtraOptions
- profilerExtraOptions=profilerExtraOptions.replace("__","--")
- profilerOptions += " %s" %profilerExtraOptions
+ profilerExtraOptions = profilerExtraOptions.replace("__","--")
+ profilerOptions += " %s" % profilerExtraOptions
# now we look for the full path of the profiler: is it really there?
import distutils.spawn
profilerPath = distutils.spawn.find_executable(profilerExecName)
- if profilerPath == None:
- root_logger.error("Cannot locate profiler %s" %profilerExecName )
+ if not profilerPath:
+ root_logger.error("Cannot locate profiler %s" % profilerExecName)
sys.exit(1)
root_logger.info("------ Profiling options are on ------ \n"\
" o Profiler: %s\n"\
" o Options: '%s'.\n"\
- " o Output: %s" %(profilerExecName,profilerOptions,profilerOutput))
+ " o Output: %s" % (profilerExecName, profilerOptions, profilerOutput))
# We profile python
profilerOptions += " python"
# now we have all the ingredients to prepare our command
- arglist = [profilerPath] +profilerOptions.split() + args
+ arglist = [profilerPath] + profilerOptions.split() + args
arglist = [ a for a in arglist if a!='' ]
#print profilerPath
#for arg in arglist: