390 def setup( self, recursive = False ):
391 if not recursive and (self._opts and (self._opts.drop_reload or self._opts.config_only)):
392
393 if self._opts.config_only is True:
394 fn = None
395 elif self._opts.config_only:
396 fn = self._opts.config_only
397 else:
398 fn = 'TempAthenaConfig.' + str(os.getpid()) + '.pkl'
399
400 if fn is not None:
401 Logging.log.info( "storing configuration in %s", fn )
402 from AthenaCommon import ConfigurationShelve
403 ConfigurationShelve.storeJobOptionsCatalogue( fn )
404 del ConfigurationShelve
405
406 if self._opts.drop_reload:
407
408
409 del sys.argv[ sys.argv.index( '--drop-and-reload' ) ]
410 for arg in sys.argv[1:]:
411 if arg[-3:] == '.py':
412 del sys.argv[ sys.argv.index( arg ) ]
413
414 elif arg == '-c':
415 idx = sys.argv.index( arg )
416 del sys.argv[ idx : idx + 2 ]
417
418
419 if self._opts.profile_python:
420 i = sys.argv.index( '--profile-python' )
421 del sys.argv[i:i+2]
422 from AthenaCommon.Debugging import dumpPythonProfile
423 dumpPythonProfile(self._opts.profile_python)
424
425
426 Logging.log.info( 'restarting athena.py from %s ... ', fn )
427 sys.argv.insert( 1, fn )
428 os.execvp( sys.argv[0], sys.argv )
429
430 else:
431
432 if self._opts.profile_python:
433 from AthenaCommon.Debugging import dumpPythonProfile
434 dumpPythonProfile(self._opts.profile_python)
435 Logging.log.info( "configuration complete, now exiting ... " )
436 os._exit( self._exitstate )
437
438
439
440
441 handle = self.getHandle()
442
443
444 handle.__dict__[
'CreateSvc'] = self.__dict__.
get(
'CreateSvc',
445 handle.CreateSvc)
446
447 from GaudiPython import AppMgr as GaudiAppMgr
448
449
450
451
452
453
454
455 import atexit
456 handler = None
457 if hasattr(atexit, '_exithandlers'):
458 for handler in atexit._exithandlers[:]:
459 if hasattr(handler[0], '__module__') and handler[0].__module__:
460 if 'audiPython' in handler[0].__module__:
461
462 atexit._exithandlers.remove( handler )
463 del handler, atexit
464
465 def _setattr( self, n, v ):
466 if n == 'CreateSvc':
467 self.__dict__[n] = v
468 return
469 if n == 'Dlls':
470 return
471 return super( GaudiAppMgr, self ).__setattr__( n, v )
472 GaudiAppMgr_old_setattr = GaudiAppMgr.__setattr__
473 GaudiAppMgr.__setattr__ = _setattr
474 del _setattr
475
476 def _getattr( self, n ):
477 if n == 'CreateSvc':
478 return self.__dict__[n]
479 return super( GaudiAppMgr, self ).__getattr__( n )
480 GaudiAppMgr_old_getattr = GaudiAppMgr.__getattr__
481 GaudiAppMgr.__getattr__ = _getattr
482 del _getattr
483
484
485
486 self.toolSvc().
setup()
487
488
489 self.serviceMgr().
setup()
490
491
492 master_seq = self.__build_master_sequence()
493 master_seq.setup()
494
495
496 handle.TopAlg = [ master_seq.getFullName() ]
497
498
499 streams = self.__dict__[ '_streams' ]
500 streams.setup()
501 handle.OutStream = list(
map(
lambda x: x.getFullName(), streams.getChildren() ))
502
503
504
505 super(AppMgr,self).__setattr__('Dlls', handle.Dlls)
506
507
508 svcMgr = self.serviceMgr()
509 _createSvc = handle.__dict__['CreateSvc']
510 if len(_createSvc) > 0 and \
511 _createSvc[0] != svcMgr.ToolSvc.getFullName():
512 _createSvc = [ svcMgr.ToolSvc.getFullName() ] + _createSvc
513
514 if 'CreateSvc' in self.__dict__:
515 del self.__dict__['CreateSvc']
516 handle.__dict__['CreateSvc'] = [ s for s in _createSvc ]
517
518
519 del handle.__dict__['CreateSvc']
520 GaudiAppMgr.__getattr__ = GaudiAppMgr_old_getattr
521 GaudiAppMgr.__setattr__ = GaudiAppMgr_old_setattr
522
523
524 Logging.log.debug( 'Updating (C++) "CreateSvc" property...' )
525 handle.CreateSvc = _createSvc
526 Logging.log.debug( 'Updating (C++) "CreateSvc" property... [ok]' )
527
528
529 if self._opts and self._opts.config_dump_file:
530 import AthenaCommon.ConfigurationShelve as cs
531 cs.saveToAscii(self._opts.config_dump_file)
532
533 return
534
bool setup(asg::AnaToolHandle< Interface > &tool, const std::string &type, const std::vector< std::string > &config, const std::string &progressFile="")
mostly useful for athena, which will otherwise re-use the previous tool
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)