917 ):
918 global _gaudi
919 if _gaudi:
920 return
921
922 sys.stdout.flush()
923
924 self.__dict__["_exit_called"] = False
925
926 self.__dict__["_gaudi_ns"] = Gaudi
927 try:
928 from GaudiKernel.Proxy.Configurable import expandvars
929 except ImportError:
930
931 def expandvars(data):
932 return data
933
934 if dllname and factname:
935 self.__dict__["_appmgr"] = gbl.Gaudi.createApplicationMgr(dllname, factname)
936 elif dllname:
937 self.__dict__["_appmgr"] = gbl.Gaudi.createApplicationMgr(dllname)
938 else:
939 self.__dict__["_appmgr"] = gbl.Gaudi.createApplicationMgr()
940 self.__dict__["_svcloc"] = gbl.Gaudi.svcLocator()
941 self.__dict__["_algmgr"] = InterfaceCast(gbl.IAlgManager)(self._appmgr)
942 self.__dict__["_evtpro"] = InterfaceCast(gbl.IEventProcessor)(self._appmgr)
943 self.__dict__["_svcmgr"] = InterfaceCast(gbl.ISvcManager)(self._appmgr)
944 self.__dict__["pyalgorithms"] = []
945 iService.__init__(self, "ApplicationMgr", self._appmgr)
946
947 if self.FSMState() < Gaudi.StateMachine.CONFIGURED:
948 self.JobOptionsType = "NONE"
949 if joboptions:
951
952 importOptions(joboptions)
953
954 import GaudiKernel.Proxy.Configurable
955
956 if hasattr(GaudiKernel.Proxy.Configurable, "applyConfigurableUsers"):
957 GaudiKernel.Proxy.Configurable.applyConfigurableUsers()
958
959 self.OutputLevel = 3
960 try:
961 appMgr = Configurable.allConfigurables["ApplicationMgr"]
962 selfprops = expandvars(appMgr.getValuedProperties())
963 except KeyError:
964 selfprops = {}
965 for p, v in selfprops.items():
966 setattr(self, p, v)
967 for p, v in selfoptions.items():
968 setattr(self, p, v)
969
970 if outputlevel != -1:
971 self.OutputLevel = outputlevel
972 self.configure()
973
974 ms = self.service("MessageSvc")
975 if "MessageSvc" in Configurable.allConfigurables:
976 msprops = Configurable.allConfigurables["MessageSvc"]
977 ms = self.service("MessageSvc")
978 if hasattr(msprops, "getValuedProperties"):
979 msprops = expandvars(msprops.getValuedProperties())
980 for p, v in msprops.items():
981 setattr(ms, p, v)
982 if outputlevel != -1:
983 ms.OutputLevel = outputlevel
984
985 for n in getNeededConfigurables():
986 c = Configurable.allConfigurables[n]
987 if n in ["ApplicationMgr", "MessageSvc"]:
988 continue
989 for p, v in c.getValuedProperties().items():
990 v = expandvars(v)
991
992 if hasattr(Configurable, "PropertyReference") and isinstance(
993 v, Configurable.PropertyReference
994 ):
995
996
997 v = v.__resolve__()
998 if isinstance(v, str):
999 v = repr(v)
1000 gbl.GaudiPython.Helpers.setProperty(
1001 self._svcloc, ".".join([n, p]), str(v)
1002 )
1003 if hasattr(Configurable, "_configurationLocked"):
1004 Configurable._configurationLocked = True
1005
1006
1007 import atexit
1008
1009 atexit.register(self.exit)
1010
1011
1012
1013
1014
1015 orig_register = atexit.register
1016
1017 def register(func, *targs, **kargs):
1018 orig_register(func, *targs, **kargs)
1019 if hasattr(func, "__module__") and func.__module__ == "ROOT":
1020 orig_register(self.exit)
1021
1022
1023
1024 register.__doc__ = (
1025 orig_register.__doc__
1026 + "\nNote: version hacked by GaudiPython to work "
1027 + "around a problem with the ROOT exit handler"
1028 )
1029 atexit.register = register
1030