ATLAS Offline Software
Execution.py
Go to the documentation of this file.
1 
2 for script in opts.scripts:
3  try:
4  include( script )
5  except Exception as e:
6  if isinstance(e,SystemExit):
7  raise
8 
9  # "sanitize" the traceback under the assumption that it is the user's fault
10  import traceback
11 
12  if not _msg.isEnabledFor( logging.DEBUG ):
13  # "sanitize" the traceback under the assumption that it is the user's fault
14  exc_info = sys.exc_info()
15  tb = traceback.extract_tb( exc_info[2] )
16 
17  short_tb = []
18  for frame_info in tb:
19  if not 'AthenaCommon' in frame_info[0]:
20  short_tb.append( frame_info )
21 
22  print ('Shortened traceback (most recent user call last):')
23  print (''.join( traceback.format_list( short_tb ) ),)
24  print (''.join( traceback.format_exception_only( exc_info[0], exc_info[1] ) ),)
25  else:
26  traceback.print_exc()
27 
28  if not opts.interactive:
29  # additional processing to get right error codes
30  import AthenaCommon.ExitCodes as ExitCodes
31  if isinstance( e, IncludeError ):
32  theApp._exitstate = ExitCodes.INCLUDE_ERROR
33  print('If the script is a ComponentAccumulator configuration, add a shebang (#!) '
34  'to its first line or run with the --CA option.\n')
35  elif isinstance( e, ImportError ):
36  theApp._exitstate = ExitCodes.IMPORT_ERROR
37  else:
38  theApp._exitstate = ExitCodes.UNKNOWN_EXCEPTION
39 
40  del ExitCodes
41  theApp.exit()
42 
43  # for interactive: drop into prompt
44  break
45 
46 else:
47 
48  if "-h" in opts.user_opts or "--help" in opts.user_opts:
49  # The user script was displaying help messages stop here
50  # In most cases, the user script should kill the process already (argparse
51  # does this for you) but just in case print our help message and stop
52  from AthenaCommon.AthOptionsParser import _error_msg
53  print(_error_msg)
54  theApp.exit()
55 
56 
57  if opts.fromdb:
58  _msg.info( 'now loading %s ... ', opts.fromdb )
59  import AthenaCommon.ConfigurationShelve
60  AthenaCommon.ConfigurationShelve.loadJobOptionsCatalogue( opts.fromdb )
61  del AthenaCommon.ConfigurationShelve
62  if opts.fromdb.startswith( 'TempAthenaConfig.' ):
63  try:
64  os.remove( opts.fromdb )
65  except OSError:
66  pass
67  opts.fromdb = None
68 
69 
70  if opts.perfmon:
71  import PerfMonComps.PerfMonFlags as _pmf
72  _pmf._decode_pmon_opts(opts.perfmon.split(','))
73 
74 
75  if DbgStage.value == "init":
76  hookDebugger()
77 
78 
79  if not opts.fromdb and opts.nprocs and (opts.nprocs >= 1 or opts.nprocs==-1):
80  from AthenaCommon.AppMgr import ServiceMgr as svcMgr
81  import AthenaMP.PyComps as _amppy
82  svcMgr += _amppy.MpEvtLoopMgr(NWorkers=opts.nprocs)
83 
84  #if EvtMax and SkipEvents are set, use them
85  from AthenaCommon.AthenaCommonFlags import jobproperties as jps
86  if jps.AthenaCommonFlags.EvtMax.statusOn:
87  theApp.EvtMax = jps.AthenaCommonFlags.EvtMax()
88  if jps.AthenaCommonFlags.SkipEvents.statusOn:
89  if hasattr(svcMgr,"EventSelector"):
90  if not hasattr(svcMgr, "SecondaryEventSelector"):
91  svcMgr.EventSelector.SkipEvents = jps.AthenaCommonFlags.SkipEvents()
92  else:
93  _msg.warning('No EventSelector in svcMgr, not skipping events')
94 
95 
96 
97  if not opts.interactive:
98 
99  include( "AthenaCommon/runbatch.py" )
100  else:
101  #pass
102  # done, back to the user
103 
104 
105  if opts.nprocs and (opts.nprocs >= 1 or opts.nprocs==-1):
106  _msg.warning('interactive mode not validated with AthenaMP')
107 
108  _msg.info( 'entered interactive mode - have fun!' )
109  _msg.info( 'you can call theApp.run() to execute and use ctrl-d to exit' )
110  os.environ['PYTHONINSPECT'] = '1'
python.Debugging.hookDebugger
def hookDebugger(debugger='gdb')
Definition: Debugging.py:22
python.Include.include
include
Definition: Include.py:318
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70