macroserver

Functions

Classes

MacroServer

Inheritance diagram of MacroServer
class MacroServer(full_name, name=None, macro_path=None, environment_db=None, recorder_path=None)[source]

Bases: MSContainer, MSObject, SardanaElementManager, SardanaIDManager

logReportKlass

alias of NonOverlappingTimedRotatingFileHandler

set_environment_db(environment_db)[source]

Sets the environment database.

Parameters:

env_db – environment database name

Return type:

None

set_macro_path(macro_path)[source]

Sets the macro path.

Parameters:

macro_path (Sequence[str]) – macro path

Return type:

None

set_recorder_path(recorder_path)[source]

Sets the recorder path.

Parameters:

recorder_path (Sequence[str]) – recorder path

Return type:

None

report(msg, *args, **kwargs)[source]

Record a log message in the sardana report (if enabled) with default level INFO. The msg is the message format string, and the args are the arguments which are merged into msg using the string formatting operator. (Note that this means that you can use keywords in the format string, together with a single dictionary argument.)

kwargs are the same as logging.Logger.debug() plus an optional level kwargs which has default value INFO

Example:

self.report("this is an official report!")
Parameters:
  • msg (str) – the message to be recorded

  • args (Any) – list of arguments

  • kwargs (Any) – list of keyword arguments

Return type:

None

set_pool_names(pool_names)[source]

Registers a new list of device pools in this manager

Parameters:

pool_names (Sequence[str]) – sequence of pool names

Return type:

None

get_pool_names()[source]

Returns the list of names of the pools this macro server is connected to.

Return type:

Sequence[str]

Returns:

the list of names of the pools this macro server is connected to

get_pool(pool_name)[source]

Returns the device pool object corresponding to the given device name or None if no match is found.

Parameters:

pool_name (str) – device pool name

Return type:

Pool

Returns:

Pool object or None if no match is found

get_pools()[source]

Returns the list of pools this macro server is connected to.

Return type:

Sequence[Pool]

Returns:

the list of pools this macro server is connected to

get_default_pool()[source]

Returns the pool defined in the DefaultPool environmental variable

property max_parallel_macros

maximum number of macros which can execute at the same time

reload_macro_lib(lib_name)[source]

Reloads the given library(=module) names.

Raises:

LibraryError in case the reload process is not successful

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

  • path – a list of absolute path to search for libraries [default: None, means the current MacroPath will be used]

Returns:

the MacroLibrary object for the reloaded macro library

get_macros(filter=None)[source]

Returns a dict containing information about macros.

Parameters:

filter – a regular expression for macro names [default: None, meaning all macros]

Returns:

a dict containing information about macros

get_macro_classes()[source]

Returns a dict containing information about macro classes.

Parameters:

filter – a regular expression for macro names [default: None, meaning all macros]

Returns:

a dict containing information about macro classes

get_macro_functions()[source]

Returns a dict containing information about macro functions.

Parameters:

filter – a regular expression for macro names [default: None, meaning all macros]

Returns:

a dict containing information about macro functions

get_or_create_macro_lib(lib_name, macro_name=None)[source]

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

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

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

Return type:

Tuple[str, str, int]

Returns:

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

get_env(key=None, door_name=None, macro_name=None)[source]

Gets the environment matching the given parameters:

  • door_name and macro_name define the context where to look for the environment. If both are None, the global environment is used. If door name is None but macro name not, the given macro environment is used and so on…

  • If key is None it returns the complete environment, otherwise key must be a string containing the environment variable name.

Parameters:
  • key (Optional[str]) – environment variable name [default: None, meaning all environment]

  • door_name (Optional[str]) – local context for a given door [default: None, meaning no door context is used]

  • macro_name (Optional[str]) – local context for a given macro [default: None, meaning no macro context is used]

Return type:

Dict

Returns:

a dict containing the environment

Raises:

UnknownEnv

set_env(key, value)[source]

Sets the environment key to the new value and stores it persistently.

Parameters:
  • key – the key for the environment

  • value – the value for the environment

Returns:

a tuple with the key and value objects stored

set_env_obj(data)[source]

Sets the environment key to the new value and stores it persistently.

Parameters:
  • key – the key for the environment

  • value – the value for the environment

Returns:

a tuple with the key and value objects stored

unset_env(key)[source]

Unsets the environment for the given key.

Parameters:

key – the key for the environment to be unset