| # Gaudi Framework, version v23r1 |

Home |  | Generated: Wed Feb 29 2012

Classes | Functions | Variables

# 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__
| data ---------------------------------------------------------------------
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 1309 of file Configurable.py.

    01310                                     :
    01311     """
    01312     Add a new callable ('function') to the list of post-configuration actions.
    01313     If the callable is already in the list, it is moved to the end of the list.
    01314     The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.
    01315     """
    01316     try:
    01317         postConfigActions.remove(function)
    01318     except:
    01319         pass
        postConfigActions.append(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 1328 of file Configurable.py.

    01329                             :
    01330     """
    01331     Call the apply method of all the ConfigurableUser instances respecting the
    01332     dependencies. First the C.U.s that are not used by anybody, then the used
    01333     ones, when they are not used anymore.
    01334     """
    01335     # Avoid double calls
    01336     global _appliedConfigurableUsers_, postConfigActions
    01337     if _appliedConfigurableUsers_:
    01338         return
    01339     _appliedConfigurableUsers_ = True
    01340
    01341     confUsers = [ c
    01342                   for c in Configurable.allConfigurables.values()
    01343                   if hasattr(c,"__apply_configuration__") ]
    01344     applied = True # needed to detect dependency loops
    01345     while applied and confUsers:
    01346         newConfUsers = [] # list of conf users that cannot be applied yet
    01347         applied = False
    01348         for c in confUsers:
    01349             if hasattr(c,"__users__") and c.__users__:
    01350                 newConfUsers.append(c) # cannot use this one yet
    01351             else: # it does not have users or the list is empty
    01352                 applied = True
    01353                 # the ConfigurableUser is enabled if it doesn't have an _enabled
    01354                 # property or its value is True
    01355                 enabled = (not hasattr(c, "_enabled")) or c._enabled
    01356                 if enabled:
    01357                     log.info("applying configuration of %s", c.name())
    01358                     c.__apply_configuration__()
    01359                     log.info(c)
    01360                 else:
    01361                     log.info("skipping configuration of %s", c.name())
    01362                 if hasattr(c, "__detach_used__"):
    01363                     # tells the used configurables that they are not needed anymore
    01364                     c.__detach_used__()
    01365         confUsers = newConfUsers # list of C.U.s still to go
    01366     if confUsers:
    01367         # this means that some C.U.s could not be applied because of a dependency loop
    01368         raise Error("Detected loop in the ConfigurableUser "
    01369                     " dependencies: %r" % [ c.name()
    01370                                             for c in confUsers ])
    01371     # Call post-config actions
    01372     for action in postConfigActions:
    01373         action()

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.

    00028                     :
    00029     """
    00030     Expand environment variables "data".
    00031     Data can be string, list, tuple and dictionary. For collection, all the
    00032     contained strings will be manipulated (recursively).
    00033     """
    00034     import os.path
    00035     typ = type(data)
    00036     if typ is str:
    00037         return os.path.expandvars(data)
    00038     elif typ in [list, tuple]:
    00039         collect = []
    00040         for i in data:
    00041             collect.append(expandvars(i))
    00042         return typ(collect)
    00043     elif typ is dict:
    00044         collect = {}
    00045         for k in data:
    00046             collect[expandvars(k)] = expandvars(data[k])
    00047         return collect
    00048     return data

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

    01375                             :
    01376     """
    01377     Function to select all and only the configurables that have to be used in
    01378     GaudiPython.AppMgr constructor.
    01379     This is needed because in Athena the implementation have to be different (the
    01380     configuration is used in a different moment).
    01381     """
    01382     return [ k
    01383              for k, v in Configurable.allConfigurables.items()
    01384              if v.getGaudiType() != "User" ] # Exclude ConfigurableUser instances

def Configurable::purge | ( | ) |

    Clean up all configurations and configurables.

Definition at line 1385 of file Configurable.py.

    01386            :
    01387     """
    01388     Clean up all configurations and configurables.
    01389     """
    01390     for c in Configurable.allConfigurables.values():
    01391         c.__class__.configurables.clear()
    01392     Configurable.allConfigurables.clear()
    01393     # FIXME: (MCl) this is needed because instances of ConfigurableGeneric are not
    01394     #        migrated to the correct class when this is known.
    01395     ConfigurableGeneric.configurables.clear()
    01396     from ProcessJobOptions import _included_files
    01397     import os.path, sys
    01398     for file in _included_files:
    01399         dirname, basname = os.path.split(file)
    01400         basname, ext = os.path.splitext(basname)
    01401         if basname in sys.modules:
    01402             del sys.modules[basname]
    01403     _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 1320 of file Configurable.py.

    01321                                     :
    01322     """
    01323     Remove a collable from the list of post-config actions.
    01324     The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.
    01325     """
    01326     postConfigActions.remove(function)

## Variable Documentation

list Configurable::__all__

Initial value:

    00001 [ 'Configurable',
    00002             'ConfigurableAlgorithm',
    00003             'ConfigurableAlgTool',
    00004             'ConfigurableAuditor',
    00005             'ConfigurableService',
    00006             'ConfigurableUser',
    00007             'VERBOSE','DEBUG','INFO', 'WARNING', 'ERROR', 'FATAL',
    00008             'appendPostConfigAction', 'removePostConfigAction' ]

data ---------------------------------------------------------------------

Definition at line 14 of file Configurable.py.

Configurable::_appliedConfigurableUsers_ = False

Definition at line 1327 of file Configurable.py.

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

Definition at line 25 of file Configurable.py.

list Configurable::postConfigActions = []

Definition at line 1308 of file Configurable.py.

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines