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)
90 from AthenaCommon.Utils.unixtools
import FindFile
91 path_list = [
'./'] + os.environ.get(
'PYTHONPATH',
'').
split(os.pathsep)
92 file_path = FindFile( os.path.expanduser( os.path.expandvars(opts.scripts[0]) ),
95 if file_path
is not None:
96 with open(file_path)
as f:
97 if f.readline().startswith(
'#!'):
101 sys.argv.remove(opts.scripts[0])
102 opts.scripts[0] = file_path
106 with open(opts.fromdb,
'rb')
as f:
109 opts.CA =
not isinstance(acc, dict)
112 except ModuleNotFoundError:
116if 'LD_PRELOAD_ORIG' in os.environ:
117 os.environ[
'LD_PRELOAD'] = os.getenv(
'LD_PRELOAD_ORIG')
118 os.unsetenv(
'LD_PRELOAD_ORIG')
121from AthenaCommon.Debugging
import DbgStage
122DbgStage.value = opts.debug
125if not os.getcwd()
in sys.path:
126 sys.path = [ os.getcwd() ] + sys.path
128if '' not in sys.path:
129 sys.path = [
'' ] + sys.path
138 from ctypes.util
import find_library
as ctypes_find_library
139 libc = ctypes.cdll.LoadLibrary( ctypes_find_library(
'c') )
140 libc.prctl( 15, b
'athena.py', 0, 0, 0 )
146if not (opts.interactive
or opts.debug):
148 if sys.stdin
and os.isatty( sys.stdin.fileno() ):
149 os.close( sys.stdin.fileno() )
158 from AthenaCommon
import ExitCodes
162 if not opts.tracelevel:
164 runpy.run_path( opts.scripts[0], run_name=
'__main__' )
166 from AthenaCommon.Debugging
import traceExecution
167 traceExecution( opts.scripts[0], opts.tracelevel )
170 from AthenaCommon.AthOptionsParser
import configureCAfromArgs
171 configureCAfromArgs( acc, opts )
172 sys.exit(acc.run(opts.evtMax).isFailure())
174 except SystemExit
as e:
176 exitcode = ExitCodes.EXE_ALG_FAILURE
if e.code==1
else e.code
178 from AthenaCommon
import Logging
179 Logging.log.info(
'leaving with code %d: "%s"',
180 exitcode, ExitCodes.what(exitcode) )
186 from AthenaCommon.Logging
import logging, log
191 _msg.setLevel (getattr(logging, opts.loglevel))
196 if opts.profile_python:
201 cProfile._athena_python_profiler = cProfile.Profile()
202 cProfile._athena_python_profiler.enable()
205 aop.fill_athenaCommonFlags(opts)
208 from AthenaCommon.Include
import include
209 include.setShowIncludes(opts.showincludes)
212 include(
"AthenaCommon/Preparation.py" )
215 include(
"AthenaCommon/Execution.py" )
std::vector< std::string > split(const std::string &s, const std::string &t=":")