| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

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 for cfg in self.__children: 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::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::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 1243 of file Configurable.py.

01243                                     :
01244     """
01245     Add a new callable ('function') to the list of post-configuration actions.
01246     If the callable is already in the list, it is moved to the end of the list.
01247     The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.
01248     """
01249     try:
01250         postConfigActions.remove(function)
01251     except:
01252         pass
01253     postConfigActions.append(function)
def removePostConfigAction(function):

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

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

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

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

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

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

def Configurable::purge (  ) 

Clean up all configurations and configurables.

Definition at line 1319 of file Configurable.py.

01319            :
01320     """
01321     Clean up all configurations and configurables.
01322     """
01323     for c in Configurable.allConfigurables.values():
01324         c.__class__.configurables.clear()
01325     Configurable.allConfigurables.clear()
01326     # FIXME: (MCl) this is needed because instances of ConfigurableGeneric are not
01327     #        migrated to the correct class when this is known.
01328     ConfigurableGeneric.configurables.clear()
01329     from ProcessJobOptions import _included_files
01330     import os.path, sys
01331     for file in _included_files:
01332         dirname, basname = os.path.split(file)
01333         basname, ext = os.path.splitext(basname)
01334         if basname in sys.modules:
01335             del sys.modules[basname]
01336     _included_files.clear()
    _included_files.clear()


Variable Documentation

list Configurable::__all__ [static]

Initial value:

[ 'Configurable',
            'ConfigurableAlgorithm',
            'ConfigurableAlgTool',
            'ConfigurableAuditor',
            'ConfigurableService',
            'ConfigurableUser',
            'VERBOSE','DEBUG','INFO', 'WARNING', 'ERROR', 'FATAL',
            'appendPostConfigAction', 'removePostConfigAction' ]

Definition at line 14 of file Configurable.py.

tuple Configurable::log = logging.getLogger( 'Configurable' ) [static]

Definition at line 25 of file Configurable.py.

list Configurable::postConfigActions = [] [static]

Definition at line 1242 of file Configurable.py.

Configurable::_appliedConfigurableUsers_ = False [static]

Definition at line 1261 of file Configurable.py.

| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:57:16 2011 for GaudiKernel by doxygen 1.4.7