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 (seq<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.

Returns:

sequence of absolute paths

Return type:

seq<str>

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.

:param str lib_name: module name, python file name, or full file

name (with path)

:param str controller_name: 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)

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.

Return type:

tuple<str, str, int>

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.

:param str lib_name: name of the new library :param str code: 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 (seq<str>) – a list of absolute path to search for libraries [default: None, meaning the current ControllerPath will be used]

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 (seq<str>) – a list of controller class names

  • path (seq<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 (seq<str>) – a list of module names

  • path (seq<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 (seq<str>) – a list of absolute path to search for libraries [default: None, meaning the current ControllerPath will be used]

Returns:

the ControllerLib object for the reloaded controller lib

Return type:

sardana.pool.poolmetacontroller.ControllerLibrary

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.

Returns:

a list containning an abreviated version of the par_list argument.

Return type:

list<str>