macroserver
Functions
Classes
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 (
str
) – environment database name
- set_macro_path(macro_path)[source]
Sets the macro path.
- Parameters:
macro_path (seq<str>) – macro path
- set_recorder_path(recorder_path)[source]
Sets the recorder path.
- Parameters:
recorder_path (seq<str>) – recorder path
- 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 INFOExample:
self.report("this is an official report!")
- Parameters:
msg (
str
) – the message to be recordedargs – list of arguments
kwargs – list of keyword arguments
- set_pool_names(pool_names)[source]
Registers a new list of device pools in this manager
- Parameters:
pool_names (seq<str>) – sequence of pool names
- get_pool_names()[source]
Returns the list of names of the pools this macro server is connected to.
- Returns:
the list of names of the pools this macro server is connected to
- Return type:
seq<str>
- 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- Returns:
Pool object or None if no match is found
- get_pools()[source]
Returns the list of pools this macro server is connected to.
- Returns:
the list of pools this macro server is connected to
- Return type:
seq<Pool>
- 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_macro_classes()[source]
Returns a
dict
containing information about macro classes.
- get_macro_functions()[source]
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:
- 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.
- Return type:
seq<str, str, int>
- 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:
- Returns:
a
dict
containing the environment- Return type:
- 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