3 from AthenaCommon.Logging
import logging
4 from AthenaCommon.CFElements
import isSequence
6 from GaudiKernel.GaudiHandles
import PrivateToolHandle, PrivateToolHandleArray
10 msg = logging.getLogger(
'PropSetterProxy')
22 if name.startswith(
"_PropSetterProxy"):
23 return super(PropSetterProxy, self).
__setattr__(name, value)
25 if name !=
"OutputLevel":
26 msg.error(
"foreach_component is a debugging feature and should not be used in production jobs, remove it before committing to the repository, proceeding to set the properties now" )
29 for component_path, component
in PropSetterProxy.__compPaths.items():
30 if fnmatch.fnmatch( component_path, self.
__path ):
32 if name
in component._descriptors:
34 setattr( component, name, value )
35 msg.info(
"Set property %s to %s for component %s because it matched '%s'",
36 name, value, component_path, self.
__path )
37 except Exception
as ex:
38 msg.warning(
"Failed to set property %s to value %s for component %s: %s",
39 name, value, component_path, ex )
41 msg.warning(
"Property %s does not exist for component %s",
42 name, component_path )
45 msg.warning(
"No components found matching '%s'", self.
__path)
49 if ca
is not PropSetterProxy.__scannedCA:
50 PropSetterProxy.__scannedCA = ca
51 PropSetterProxy.__compPaths = {}
52 def __add(path, comp):
53 if comp.getName() ==
"":
55 PropSetterProxy.__compPaths[ path ] = comp
58 for svc
in ca._services:
59 PropSetterProxy.__compPaths[
'SvcMgr/'+svc.getFullJobOptName()] = svc
60 for t
in ca._publicTools:
61 PropSetterProxy.__compPaths[
'ToolSvc/'+t.getFullJobOptName()] = t
62 for t
in ca._conditionsAlgs:
63 PropSetterProxy.__compPaths[t.getFullJobOptName()] = t
65 for t
in ca._privateTools:
66 PropSetterProxy.__compPaths[t.getFullJobOptName()] = t
68 def __nestAlg(startpath, comp):
69 if comp.getName() ==
"":
71 for name, value
in comp._descriptors.items():
72 if isinstance( value.cpp_type, ConfigurableAlgTool )
or isinstance( value.cpp_type, PrivateToolHandle ):
73 __add( startpath+
"/"+name+
"/"+value.getFullJobOptName(), value )
74 __nestAlg( startpath+
"/"+name+
"/"+value.getName(), value )
75 if isinstance( value.cpp_type, PrivateToolHandleArray):
76 for toolIndex,t
in enumerate(value):
77 __add( startpath+
"/"+name+
"/"+t.getFullJobOptName(), t )
78 __nestAlg( startpath+
"/"+name+
"/"+t.getName(), value[toolIndex] )
81 def __nestSeq( startpath, seq ):
84 __nestSeq( startpath+
"/"+c.getName(), c )
86 __add( startpath+
"/"+c.getFullJobOptName(), c )
87 __nestAlg( startpath+
"/"+c.getFullJobOptName(), c )
89 __nestSeq(
"", ca._sequence)