poolcontrollermanager

This module is part of the Python Pool library. It defines the class which controls finding, loading/unloading of device pool controller plug-ins.

Classes

ControllerManager

Inheritance diagram of ControllerManager
class ControllerManager(*p, **k)[source]

Bases: Singleton, Logger

The singleton class responsible for managing controller plug-ins.

DEFAULT_CONTROLLER_DIRECTORIES = ('poolcontrollers',)
init(*args, **kwargs)[source]

Singleton instance initialization.

reInit()[source]

Singleton re-initialization.

cleanUp()[source]

Singleton clean up.

set_pool(pool)[source]
get_pool()[source]
setControllerPath(controller_path, reload=True)[source]

Registers a new list of controller directories in this manager.

Parameters:

controller_path (Sequence[str]) – a sequence of absolute paths where this manager should look for controllers

Warning

as a consequence all the controller modules will be reloaded. This means that if any reference to an old controller object was kept it will refer to an old module (which could possibly generate problems of type class A != class A).

getControllerPath()[source]

Returns the current sequence of absolute paths used to look for controllers.

Return type:

Sequence[str]

Returns:

sequence of absolute paths

getOrCreateControllerLib(lib_name, controller_name=None)[source]

Gets the exiting controller lib or creates a new controller lib file. If name is not None, a controller template code for the given controller name is appended to the end of the file.

Parameters:
  • lib_name (str) – module name, python file name, or full file name (with path)

  • controller_name (Optional[str]) – an optional controller name. If given a controller template code is appended to the end of the file [default: None, meaning no controller code is added)

Return type:

Tuple[str, str, int]

Returns:

a sequence with three items: full_filename, code, line number line number is 0 if no controller is created or n representing the first line of code for the given controller name.

setControllerLib(lib_name, code)[source]

Creates a new controller library file with the given name and code. The new module is imported and becomes imediately available.

Parameters:
  • lib_name (str) – name of the new library

  • code (str) – python code of the new library

createControllerLib(lib_name, path=None)[source]

Creates a new empty controller library (python module)

createController(lib_name, controller_name)[source]

Creates a new controller

reloadController(controller_name, path=None)[source]

Reloads the module corresponding to the given controller name

Raises:

sardana.pool.poolexception.UnknownController in case the controller is unknown or ImportError if the reload process is not successfull

Parameters:
  • controller_name (str) – controller class name

  • path (Optional[Sequence[str]]) – a list of absolute path to search for libraries [default: None, meaning the current ControllerPath will be used]

Return type:

None

reloadControllers(controller_names, path=None)[source]

Reloads the modules corresponding to the given controller names

Raises:

sardana.pool.poolexception.UnknownController in case the controller is unknown or ImportError if the reload process is not successful

Parameters:
  • controller_names (Sequence[str]) – a list of controller class names

  • path (Optional[Sequence[str]]) – a list of absolute path to search for libraries [default: None, meaning the current ControllerPath will be used]

reloadControllerLibs(module_names, path=None, reload=True)[source]

Reloads the given library(=module) names

Raises:

sardana.pool.poolexception.UnknownController in case the controller is unknown or ImportError if the reload process is not successful

Parameters:
  • module_names (Sequence[str]) – a list of module names

  • path (Optional[Sequence[str]]) – a list of absolute path to search for libraries [default: None, meaning the current ControllerPath will be used]

reloadControllerLib(module_name, path=None, reload=True)[source]

Reloads the given library(=module) names

Raises:

sardana.pool.poolexception.UnknownController in case the controller is unknown or ImportError if the reload process is not successful

Parameters:
  • module_name (str) – controller library name (=python module name)

  • path (Optional[Sequence[str]]) – a list of absolute path to search for libraries [default: None, meaning the current ControllerPath will be used]

Return type:

ControllerLibrary

Returns:

the ControllerLib object for the reloaded controller lib

addController(controller_lib, klass)[source]

Adds a new controller class

getControllerNames()[source]
getControllerLibNames()[source]
getControllerLibs(filter=None)[source]
getControllers(filter=None)[source]
getControllerMetaClass(controller_name)[source]
getControllerMetaClasses(controller_names)[source]
getControllerLib(name)[source]
getControllerClass(controller_name)[source]
decodeControllerParameters(in_par_list)[source]
strControllerParamValues(par_list)[source]

Creates a short string representation of the parameter values list.

Parameters:

par_list (List[str]) – list of strings representing the parameter values.

Return type:

List[str]

Returns:

a list containning an abreviated version of the par_list argument.