Gaudi Framework, version v20r4

Generated: 8 Jan 2009

Configurable Namespace Reference


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


Function Documentation

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 1247 of file Configurable.py.

01247                                     :
01248     """
01249     Add a new callable ('function') to the list of post-configuration actions.
01250     If the callable is already in the list, it is moved to the end of the list.
01251     The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.
01252     """
01253     try:
01254         postConfigActions.remove(function)
01255     except:
01256         pass
01257     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 1266 of file Configurable.py.

01266                             :
01267     """
01268     Call the apply method of all the ConfigurableUser instances respecting the
01269     dependencies. First the C.U.s that are not used by anybody, then the used
01270     ones, when they are not used anymore.
01271     """
01272     # Avoid double calls
01273     global _appliedConfigurableUsers_, postConfigActions
01274     if _appliedConfigurableUsers_:
01275         return
01276     _appliedConfigurableUsers_ = True
01277     
01278     confUsers = [ c
01279                   for c in Configurable.allConfigurables.values()
01280                   if hasattr(c,"__apply_configuration__") ]
01281     applied = True # needed to detect dependency loops
01282     while applied and confUsers:
01283         newConfUsers = [] # list of conf users that cannot be applied yet
01284         applied = False
01285         for c in confUsers:
01286             if hasattr(c,"__users__") and c.__users__:
01287                 newConfUsers.append(c) # cannot use this one yet
01288             else: # it does not have users or the list is empty
01289                 applied = True
01290                 # the ConfigurableUser is enabled if it doesn't have an _enabled
01291                 # property or its value is True 
01292                 enabled = (not hasattr(c, "_enabled")) or c._enabled
01293                 if enabled:
01294                     log.info("applying configuration of %s", c.name())
01295                     c.__apply_configuration__()
01296                     log.info(c)
01297                 else:
01298                     log.info("skipping configuration of %s", c.name())
01299                 if hasattr(c, "__detach_used__"):
01300                     # tells the used configurables that they are not needed anymore
01301                     c.__detach_used__()
01302         confUsers = newConfUsers # list of C.U.s still to go
01303     if confUsers:
01304         # this means that some C.U.s could not be applied because of a dependency loop
01305         raise Error("Detected loop in the ConfigurableUser "
01306                     " dependencies: %r" % [ c.name()
01307                                             for c in confUsers ])
01308     # Call post-config actions
01309     for action in postConfigActions:
01310         action()
01311 
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 1312 of file Configurable.py.

01312                             :
01313     """
01314     Function to select all and only the configurables that have to be used in
01315     GaudiPython.AppMgr constructor.
01316     This is needed because in Athena the implementation have to be different (the
01317     configuration is used in a different moment).
01318     """
01319     return [ k
01320              for k, v in Configurable.allConfigurables.items()
01321              if v.getGaudiType() != "User" ] # Exclude ConfigurableUser instances
01322 
def purge():

def Configurable::purge (  ) 

Clean up all configurations and configurables.

Definition at line 1323 of file Configurable.py.

01323            :
01324     """
01325     Clean up all configurations and configurables.
01326     """
01327     for c in Configurable.allConfigurables.values():
01328         c.__class__.configurables.clear()
01329     Configurable.allConfigurables.clear()
01330     # FIXME: (MCl) this is needed because instances of ConfigurableGeneric are not
01331     #        migrated to the correct class when this is known.
01332     ConfigurableGeneric.configurables.clear()
01333     from ProcessJobOptions import _included_files
01334     import os.path, sys
01335     for file in _included_files:
01336         dirname, basname = os.path.split(file)
01337         basname, ext = os.path.splitext(basname)
01338         if basname in sys.modules:
01339             del sys.modules[basname]
01340     _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 1258 of file Configurable.py.

01258                                     :
01259     """
01260     Remove a collable from the list of post-config actions. 
01261     The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.
01262     """
01263     postConfigActions.remove(function)
01264 
_appliedConfigurableUsers_ = False


Variable Documentation

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 1265 of file Configurable.py.

tuple Configurable::log = logging.getLogger( 'Configurable' )

Definition at line 25 of file Configurable.py.

Definition at line 1246 of file Configurable.py.


Generated at Thu Jan 8 17:53:35 2009 for Gaudi Framework, version v20r4 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004