Sardana custom settings
Sardana provides a module located at its root directory called
sardanacustomsettings
which exposes global configuration options.
It can be accessed programmatically at run time for setting options for the current execution.
System and user settings files
If one wants to permanently modify options for all applications, the
recommended way is to do it by declaring them in the system-wide or
user-specific configuration files (which are loaded automatically when
importing sardanacustomsettings
).
The default location of the system-wide and user-specific configuration
files is set in SYSTEM_CFG_FILE
and
USER_CFG_FILE
, respectively. The values are
platform-dependent:
on posix systems we use:
/etc/sardana/sardana.ini
for system and~/.sardana/sardana.ini
for user.on windows machines we use
%PROGRAMDATA%\sardana\sardana.ini
for system and%APPDATA%\sardana\sardana.ini
for user
In case of conflict, the user settings take precedence over the system settings.
Custom setting file locations
One can also programmatically call the load_configs()
function at any point to load other configuration files.
In both cases, the values of existing variables in sardanacustomsettings
are overwritten in case of conflict).
Format of the settings files
The settings files are plain-text .ini files of the form:
[sardana]
FOO = "bar"
BAR = [1, 2, 3]
baz = False
The keys, which are key-sensitive, are exposed as sardanacustomsettings
variables and their values are parsed as python literals (e.g., in the above example,
sardanacustomsettings.FOO
would be the bar
string,
sardanacustomsettings.BAR
would be a list and sardanacustomsettings.baz
would be a boolean).
Note that all key-values must be declared within a [sardana]
section.
This module contains some Sardana-wide default configurations. It declares the default values of some of these options, but they may be modified when loading custom settings configuration files (e.g., at import time).
- SYSTEM_CFG_FILE = '/etc/sardana/sardana.ini'
Path to the system-wide config file
- USER_CFG_FILE = '/home/mambauser/.sardana/sardana.ini'
Path to the user-specific config file
- load_configs(filenames=None, section='sardana')[source]
Read configuration key, values from given ini files and expose them as members of the current module.
The keys must appear in the given section (“sardana” by default) and are case-sensitive. The values are interpreted as python literals.
In case of conflicting keys, the filenames determine the precedence (increasing order). If a given file cannot be read, it is skipped. The list of names of successfully read files is returned.
- Parameters:
- Return type:
- Returns:
list of names of successfully read configuration files
- UNITTEST_DOOR_NAME = 'door/demo1/1'
UnitTest door name: the door to be used by unit tests. UNITTEST_DOOR_NAME must be defined for running sardana unittests.
- UNITTEST_POOL_DS_NAME = 'unittest1'
UnitTests Pool DS name: Pool DS to use in unit tests.
- UNITTEST_POOL_NAME = 'pool/demo1/1'
UnitTests Pool Device name: Pool Device to use in unit tests.
- POOL_LOG_FILES_SIZE = 10000000.0
Size of rotating backups of the log files. The Pool device server will use these values for its logs.
- MS_LOG_FILES_SIZE = 10000000.0
Size of rotating backups of the log files. The MacroServer device server will use these values for its logs.
- SARDANA_LOG_FILES_SIZE = 10000000.0
Size of rotating backups of the log files. The Sardana device server will use these values for its logs.
- POOL_LOG_BCK_COUNT = 5
Number of rotating backups of the log files. The Pool device server will use these values for its logs.
- MS_LOG_BCK_COUNT = 5
Number of rotating backups of the log files. The MacroServer device server will use these values for its logs.
- SARDANA_LOG_BCK_COUNT = 5
Number of rotating backups of the log files. The Sardana device server will use these values for its logs.
- SPOCK_INPUT_HANDLER = 'CLI'
Input handler for spock interactive macros. Accepted values are:
“CLI”: Input via spock command line. This is the default.
“Qt”: Input via Qt dialogs
- SCAN_RECORDER_MAP = None
Use this map in order to avoid ambiguity with scan recorders (file) if extension is intended to be the recorder selector. Set it to a dict<str, str> where:
key - scan file extension e.g. “.h5”
value - recorder name
The SCAN_RECORDER_MAP will make an union with the dynamically (created map at the MacroServer startup) taking precedence in case the extensions repeats in both of them.
- LOG_MACRO_FILTER = 'sardana.macroserver.msmacromanager.LogMacroFilter'
Filter for macro logging: name of the class to be used as filter for the macro logging
if LOG_MACRO_FILTER is not defined no filter will be used
if LOG_MACRO_FILTER is wrongly defined a user warning will be issued and no filter will be used
if LOG_MACRO_FILTER is correctly defined but macro filter can not be initialized a user warning will be issued and no filter will be used
- VALUE_BUFFER_CODEC = 'pickle'
Type of encoding for ValueBuffer Tango attribute of experimental channels
- VALUE_REF_BUFFER_CODEC = 'pickle'
Type of encoding for ValueRefBuffer Tango attribute of experimental channels
- MS_ENV_SHELVE_BACKEND = None
Database backend for MacroServer environment implemented using shelve. Available options:
None (default) - first try “gnu” and if not available fallback to “dumb”
“gnu” - better performance than dumb, but requires installation of additional package e.g. python3-gdbm on Debian. At the time of writing of this documentation it is not available for conda.
“dumb” - worst performance but directly available with Python 3.
- MACROEXECUTOR_MAX_HISTORY = 100
macroexecutor maximum number of macros stored in the history. Available options:
None (or no setting) - unlimited history (may slow down the GUI operation if grows too big)
0 - history will not be filled
<int> - max number of macros stored in the history
- PRE_POST_MOVE_HOOK_IN_MV = True
pre-move and post-move hooks applied in simple mv-based macros Available options:
True (or no setting) - macros which are hooked to the pre-move and post-move hook places are called before and/or after any move of a motor
False - macros which are hooked to the pre-move and post-move hook places are not called in simple mv-based macros but only in scan-based macros
- SPEC_CUSTOM_DATA_FORMAT = '#UVAR {name} {value}\n'
Default SPEC recorder custom data format. Custom data can be added using
DataHandler.addCustomData()
and this default format can be changed with thespec_custom_fmt
kwarg of this method.For backward compatibility change to:
#C {name} : {value}\n
.
- NXSCANH5_RECORDER_LINK_PRE_SCAN_SNAPSHOT = False
Duplicate the pre_scan_snapshot fields into the measurement collection via SoftLinks for the NXscanH5_recorder#: Available options:
False (or no setting) - pre_scan_snapshot fields are not duplicated
True - pre_scan_snapshot fields are duplicated into the measurement collection via SoftLinks
- USE_NUMERIC_ELEMENT_IDS = False
Use numeric IDs to identify elements in configuration
- USE_PHYSICAL_ROLES_PROPERTY = True
Use
physical_roles
new Tango device property for Controller class device (pseudo controllers) instead of the old onesmotor_role_ids
andcounter_role_ids
.
- LOG_MESSAGE_CODEC = None
Use a custom encoding for log data between the server and the client. By default Tango uses Latin1 character encoding for DevString types. To allow non-ASCII characters in logging (including macro output()s!), messages can be encoded before setting them as Tango attribute values. Note that the server and the client should have the same codec set.
None (or no setting): do not do any encoding, transfer log messages intact.
otherwise the name of a codec registered in the codec factory (taurus.core.util.codecs.CodecFactory), e.g. ‘utf8’ or ‘pickle’.