|
Gaudi Framework, version v21r7 |
| Home | Generated: 22 Jan 2010 |
Classes | |
| class | Error |
| class | PropertyReference |
| Allow references to options as in old style. More... | |
| class | Configurable |
| class | DummyDescriptor |
| if isinstance(v,Configurable) and not v.isPublic(): rep += v.__str__( indent + 1 ) + os.linesep elif isinstance(v,GaudiHandleArray): for vi in v: if isinstance(vi,Configurable) and not vi.isPublic(): rep += vi.__str__( indent + 1 ) + os.linesep More... | |
| class | ConfigurableGeneric |
| class | ConfigurableAlgorithm |
| class | ConfigurableService |
| class | ConfigurableAlgTool |
| class | ConfigurableAuditor |
| class | ConfigurableUser |
Functions | |
| def | expandvars |
| def | appendPostConfigAction |
| def | removePostConfigAction |
| def | applyConfigurableUsers |
| def | getNeededConfigurables |
| def | purge |
Variables | |
| list | __all__ |
| tuple | log = logging.getLogger( 'Configurable' ) |
| list | postConfigActions = [] |
| _appliedConfigurableUsers_ = False | |
| def Configurable::appendPostConfigAction | ( | function | ) |
Add a new callable ('function') to the list of post-configuration actions.
If the callable is already in the list, it is moved to the end of the list.
The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.
Definition at line 1260 of file Configurable.py.
01260 : 01261 """ 01262 Add a new callable ('function') to the list of post-configuration actions. 01263 If the callable is already in the list, it is moved to the end of the list. 01264 The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'. 01265 """ 01266 try: 01267 postConfigActions.remove(function) 01268 except: 01269 pass 01270 postConfigActions.append(function) def removePostConfigAction(function):
| def Configurable::applyConfigurableUsers | ( | ) |
Call the apply method of all the ConfigurableUser instances respecting the dependencies. First the C.U.s that are not used by anybody, then the used ones, when they are not used anymore.
Definition at line 1279 of file Configurable.py.
01279 : 01280 """ 01281 Call the apply method of all the ConfigurableUser instances respecting the 01282 dependencies. First the C.U.s that are not used by anybody, then the used 01283 ones, when they are not used anymore. 01284 """ 01285 # Avoid double calls 01286 global _appliedConfigurableUsers_, postConfigActions 01287 if _appliedConfigurableUsers_: 01288 return 01289 _appliedConfigurableUsers_ = True 01290 01291 confUsers = [ c 01292 for c in Configurable.allConfigurables.values() 01293 if hasattr(c,"__apply_configuration__") ] 01294 applied = True # needed to detect dependency loops 01295 while applied and confUsers: 01296 newConfUsers = [] # list of conf users that cannot be applied yet 01297 applied = False 01298 for c in confUsers: 01299 if hasattr(c,"__users__") and c.__users__: 01300 newConfUsers.append(c) # cannot use this one yet 01301 else: # it does not have users or the list is empty 01302 applied = True 01303 # the ConfigurableUser is enabled if it doesn't have an _enabled 01304 # property or its value is True 01305 enabled = (not hasattr(c, "_enabled")) or c._enabled 01306 if enabled: 01307 log.info("applying configuration of %s", c.name()) 01308 c.__apply_configuration__() 01309 log.info(c) 01310 else: 01311 log.info("skipping configuration of %s", c.name()) 01312 if hasattr(c, "__detach_used__"): 01313 # tells the used configurables that they are not needed anymore 01314 c.__detach_used__() 01315 confUsers = newConfUsers # list of C.U.s still to go 01316 if confUsers: 01317 # this means that some C.U.s could not be applied because of a dependency loop 01318 raise Error("Detected loop in the ConfigurableUser " 01319 " dependencies: %r" % [ c.name() 01320 for c in confUsers ]) 01321 # Call post-config actions 01322 for action in postConfigActions: 01323 action() 01324 def getNeededConfigurables():
| def Configurable::expandvars | ( | data | ) |
Expand environment variables "data". Data can be string, list, tuple and dictionary. For collection, all the contained strings will be manipulated (recursively).
Definition at line 27 of file Configurable.py.
00027 : 00028 """ 00029 Expand environment variables "data". 00030 Data can be string, list, tuple and dictionary. For collection, all the 00031 contained strings will be manipulated (recursively). 00032 """ 00033 import os.path 00034 typ = type(data) 00035 if typ is str: 00036 return os.path.expandvars(data) 00037 elif typ in [list, tuple]: 00038 collect = [] 00039 for i in data: 00040 collect.append(expandvars(i)) 00041 return typ(collect) 00042 elif typ is dict: 00043 collect = {} 00044 for k in data: 00045 collect[expandvars(k)] = expandvars(data[k]) 00046 return collect 00047 return data 00048 class Error(RuntimeError):
| def Configurable::getNeededConfigurables | ( | ) |
Function to select all and only the configurables that have to be used in GaudiPython.AppMgr constructor. This is needed because in Athena the implementation have to be different (the configuration is used in a different moment).
Definition at line 1325 of file Configurable.py.
01325 : 01326 """ 01327 Function to select all and only the configurables that have to be used in 01328 GaudiPython.AppMgr constructor. 01329 This is needed because in Athena the implementation have to be different (the 01330 configuration is used in a different moment). 01331 """ 01332 return [ k 01333 for k, v in Configurable.allConfigurables.items() 01334 if v.getGaudiType() != "User" ] # Exclude ConfigurableUser instances 01335 def purge():
| def Configurable::purge | ( | ) |
Clean up all configurations and configurables.
Definition at line 1336 of file Configurable.py.
01336 : 01337 """ 01338 Clean up all configurations and configurables. 01339 """ 01340 for c in Configurable.allConfigurables.values(): 01341 c.__class__.configurables.clear() 01342 Configurable.allConfigurables.clear() 01343 # FIXME: (MCl) this is needed because instances of ConfigurableGeneric are not 01344 # migrated to the correct class when this is known. 01345 ConfigurableGeneric.configurables.clear() 01346 from ProcessJobOptions import _included_files 01347 import os.path, sys 01348 for file in _included_files: 01349 dirname, basname = os.path.split(file) 01350 basname, ext = os.path.splitext(basname) 01351 if basname in sys.modules: 01352 del sys.modules[basname] 01353 _included_files.clear() _included_files.clear()
| def Configurable::removePostConfigAction | ( | function | ) |
Remove a collable from the list of post-config actions. The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.
Definition at line 1271 of file Configurable.py.
01271 : 01272 """ 01273 Remove a collable from the list of post-config actions. 01274 The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'. 01275 """ 01276 postConfigActions.remove(function) 01277 _appliedConfigurableUsers_ = False
Initial value:
[ 'Configurable', 'ConfigurableAlgorithm', 'ConfigurableAlgTool', 'ConfigurableAuditor', 'ConfigurableService', 'ConfigurableUser', 'VERBOSE','DEBUG','INFO', 'WARNING', 'ERROR', 'FATAL', 'appendPostConfigAction', 'removePostConfigAction' ]
Definition at line 14 of file Configurable.py.
Definition at line 1278 of file Configurable.py.
| tuple Configurable::log = logging.getLogger( 'Configurable' ) |
Definition at line 25 of file Configurable.py.
Definition at line 1259 of file Configurable.py.