16# but use tcmalloc by default if TCMALLOCDIR is defined
17if [ -n "$TCMALLOCDIR" ]; then
21# parse LD_PRELOAD related command line arguments
25 --stdcmalloc) USETCMALLOC=0;;
26 --tcmalloc) USETCMALLOC=1;;
27 --stdcmath) USEIMF=0;;
29 --exctrace) USEEXCTRACE=1;;
30 --no-excabort) USEEXCABORT=0;;
31 --preloadlib*) export ATHENA_ADD_PRELOAD=${a#*=};;
32 --drop-and-reload) ATHENA_DROP_RELOAD=1;;
33 *) otherargs+=("$a");;
38# Do the actual preloading via LD_PRELOAD and save the original value
39export LD_PRELOAD_ORIG=${LD_PRELOAD}
40source `which athena_preload.sh `
42# Now resurrect ourselves as python script
43python_path=`which python`
44"exec" "$python_path" "-tt" "$0" "$@";
78__author__ =
'Wim Lavrijsen (WLavrijsen@lbl.gov)'
79__doc__ =
'For details about athena.py, run "less `which athena.py`"'
84import AthenaCommon.AthOptionsParser
as aop
86opts = aop.parse(legacy_args=
True)
89from PyUtils.Helpers
import ROOTSetup
90ROOTSetup(batch =
not opts.interactive)
94 from AthenaCommon.Utils.unixtools
import FindFile
95 path_list = [
'./'] + os.environ.get(
'PYTHONPATH',
'').
split(os.pathsep)
96 file_path = FindFile( os.path.expanduser( os.path.expandvars(opts.scripts[0]) ),
99 if file_path
is not None:
100 with open(file_path)
as f:
101 if f.readline().startswith(
'#!'):
105 sys.argv.remove(opts.scripts[0])
106 opts.scripts[0] = file_path
110 with open(opts.fromdb,
'rb')
as f:
113 opts.CA =
not isinstance(acc, dict)
116 except ModuleNotFoundError:
120if 'LD_PRELOAD_ORIG' in os.environ:
121 os.environ[
'LD_PRELOAD'] = os.getenv(
'LD_PRELOAD_ORIG')
122 os.unsetenv(
'LD_PRELOAD_ORIG')
125from AthenaCommon.Debugging
import DbgStage
126DbgStage.value = opts.debug
129if not os.getcwd()
in sys.path:
130 sys.path = [ os.getcwd() ] + sys.path
132if '' not in sys.path:
133 sys.path = [
'' ] + sys.path
142 from ctypes.util
import find_library
as ctypes_find_library
143 libc = ctypes.cdll.LoadLibrary( ctypes_find_library(
'c') )
144 libc.prctl( 15, b
'athena.py', 0, 0, 0 )
150if not (opts.interactive
or opts.debug):
152 if sys.stdin
and os.isatty( sys.stdin.fileno() ):
153 os.close( sys.stdin.fileno() )
162 from AthenaCommon
import ExitCodes
166 if not opts.tracelevel:
168 runpy.run_path( opts.scripts[0], run_name=
'__main__' )
170 from AthenaCommon.Debugging
import traceExecution
171 traceExecution( opts.scripts[0], opts.tracelevel )
174 from AthenaCommon.AthOptionsParser
import configureCAfromArgs
175 configureCAfromArgs( acc, opts )
176 sys.exit(acc.run(opts.evtMax).isFailure())
178 except SystemExit
as e:
180 exitcode = ExitCodes.EXE_ALG_FAILURE
if e.code==1
else e.code
182 from AthenaCommon
import Logging
183 Logging.log.info(
'leaving with code %d: "%s"',
184 exitcode, ExitCodes.what(exitcode) )
190 from AthenaCommon.Logging
import logging, log
195 _msg.setLevel (getattr(logging, opts.loglevel))
200 if opts.profile_python:
205 cProfile._athena_python_profiler = cProfile.Profile()
206 cProfile._athena_python_profiler.enable()
209 aop.fill_athenaCommonFlags(opts)
212 from AthenaCommon.Include
import include
213 include.setShowIncludes(opts.showincludes)
216 include(
"AthenaCommon/Preparation.py" )
219 include(
"AthenaCommon/Execution.py" )
std::vector< std::string > split(const std::string &s, const std::string &t=":")