prsctrl_gui.utility.config.AppConfig#
- class AppConfig[source]#
Bases:
objectConfiguration collection
Methods
Write configuration to files.
Substitute a string for a path
Initialize configuration
Attributes
- APP_NAME: str = 'prsctrl-gui'#
- APP_VERSION: str = '1.0.0'#
- CACHE_CFG: AppCache = AppCache(geometry_height=1020, geometry_width=1920, geometry_x=0, geometry_y=0, last_measurement_load_dir=None, last_measurement_save_dir=None, last_measurement_save_ext='.hdf5', last_power_calibration_settings=NewPowerCalibration(pump_source='laser', wavelength_nm=90.99, max_laser_power_mW=50.0, max_led_current_A=0.7, n_steps=7, beam_area_cm2=0.7), last_task_dir='/home/matth/', last_tasklist_dir='~/', global_metadata_input={})#
- CACHE_CFG_PATH: str = '/home/matth/.cache/prsctrl-gui/prsctrl-gui.yaml'#
- CACHE_DIR: str = '/home/matth/.cache/prsctrl-gui'#
- CONFIG_DIR: str = '/home/matth/.config/prsctrl-gui'#
- MAIN_CFG: AppSettings = AppSettings(app_language='en', system_path_append=[], console_history_path='<CACHE_DIR>/console-history.txt', data_dir='~/prsctrl-gui-data', data_dir_archive='~/prsctrl-gui-archive', archive_file_count_threshold=20, data_dir_cache='<CACHE_DIR>/data', reference_data_dir=None, log_dir='<CACHE_DIR>/logs', plot_max_data_points=20000, plot_update_interval_ms=10, device_auto_reconnect=True, tasklist_path='<CACHE_DIR>/tasklist.yaml', power_switch_autoconnect_devices_timeout_s=10, idle_update_interval_s=10, error_stack_trace=True, error_show_dialog=True, compress_data=True, power_switch_exe=None, smtp_settings=None, sample_db='<CONFIG_DIR>/samples.yaml', power_calibration_db='<CONFIG_DIR>/power-calibration.yaml', setup_info_db='<CONFIG_DIR>/setup-info.yaml', task_preset_dir='<CONFIG_DIR>/task-presets', device_connection_infos_path='<CACHE_DIR>/devices.yaml')#
- MAIN_CFG_PATH: str = '/home/matth/.config/prsctrl-gui/prsctrl-gui.yaml'#
- __annotations__ = {'APP_NAME': <class 'str'>, 'APP_VERSION': <class 'str'>, 'CACHE_CFG': <class 'prsctrl_gui.utility.config.AppCache'>, 'CACHE_CFG_PATH': <class 'str'>, 'CACHE_DIR': <class 'str'>, 'CONFIG_DIR': <class 'str'>, 'MAIN_CFG': <class 'prsctrl_gui.utility.config.AppSettings'>, 'MAIN_CFG_PATH': <class 'str'>}#
- __dict__ = mappingproxy({'__module__': 'prsctrl_gui.utility.config', '__firstlineno__': 167, '__annotations__': {'APP_NAME': <class 'str'>, 'APP_VERSION': <class 'str'>, 'CONFIG_DIR': <class 'str'>, 'CACHE_DIR': <class 'str'>, 'MAIN_CFG': <class 'prsctrl_gui.utility.config.AppSettings'>, 'MAIN_CFG_PATH': <class 'str'>, 'CACHE_CFG': <class 'prsctrl_gui.utility.config.AppCache'>, 'CACHE_CFG_PATH': <class 'str'>}, '__doc__': 'Configuration collection\n ', 'APP_NAME': 'prsctrl-gui', 'APP_VERSION': '1.0.0', 'CONFIG_DIR': '/home/matth/.config/prsctrl-gui', 'CACHE_DIR': '/home/matth/.cache/prsctrl-gui', 'MAIN_CFG': AppSettings(app_language='en', system_path_append=[], console_history_path='<CACHE_DIR>/console-history.txt', data_dir='~/prsctrl-gui-data', data_dir_archive='~/prsctrl-gui-archive', archive_file_count_threshold=20, data_dir_cache='<CACHE_DIR>/data', reference_data_dir=None, log_dir='<CACHE_DIR>/logs', plot_max_data_points=20000, plot_update_interval_ms=10, device_auto_reconnect=True, tasklist_path='<CACHE_DIR>/tasklist.yaml', power_switch_autoconnect_devices_timeout_s=10, idle_update_interval_s=10, error_stack_trace=True, error_show_dialog=True, compress_data=True, power_switch_exe=None, smtp_settings=None, sample_db='<CONFIG_DIR>/samples.yaml', power_calibration_db='<CONFIG_DIR>/power-calibration.yaml', setup_info_db='<CONFIG_DIR>/setup-info.yaml', task_preset_dir='<CONFIG_DIR>/task-presets', device_connection_infos_path='<CACHE_DIR>/devices.yaml'), 'MAIN_CFG_PATH': '/home/matth/.config/prsctrl-gui/prsctrl-gui.yaml', 'CACHE_CFG': AppCache(geometry_height=1020, geometry_width=1920, geometry_x=0, geometry_y=0, last_measurement_load_dir=None, last_measurement_save_dir=None, last_measurement_save_ext='.hdf5', last_power_calibration_settings=NewPowerCalibration(pump_source='laser', wavelength_nm=90.99, max_laser_power_mW=50.0, max_led_current_A=0.7, n_steps=7, beam_area_cm2=0.7), last_task_dir='/home/matth/', last_tasklist_dir='~/', global_metadata_input={}), 'CACHE_CFG_PATH': '/home/matth/.cache/prsctrl-gui/prsctrl-gui.yaml', 'initialize': <classmethod(<function AppConfig.initialize>)>, 'finalize': <classmethod(<function AppConfig.finalize>)>, 'get_path': <classmethod(<function AppConfig.get_path>)>, '__static_attributes__': (), '__dict__': <attribute '__dict__' of 'AppConfig' objects>, '__weakref__': <attribute '__weakref__' of 'AppConfig' objects>})#
- __firstlineno__ = 167#
- __module__ = 'prsctrl_gui.utility.config'#
- __static_attributes__ = ()#
- __weakref__#
list of weak references to the object
- classmethod get_path(path: None, check_can_read: bool = False, check_can_write: bool = False) None[source]#
- classmethod get_path(path: str, check_can_read: bool = False, check_can_write: bool = False) str
- classmethod get_path(path: list[str], check_can_read: bool = False, check_can_write: bool = False) list[str]
Substitute a string for a path
Substitutes:
~
<CONFIG_DIR> for
CONFIG_DIR<CACHE_DIR> for
CACHE_DIR
- Parameters:
path – String to apply substitutions to. May be None or a list of paths/None as well.
check_can_read – If True, check that the path exists and can be read. If not, raise an exception.
check_can_write – If True, check that the path exists and can be written. If not, raise an exception.
- Raises:
ValueError – If the path cannot be read or written (only when check_can_read or check_can_write is True)
- Returns:
The path with substitutions applied. If path is None, None is returned. If list of paths was given, a list is returned.
- classmethod initialize() None[source]#
Initialize configuration
Perform any necessary initializations here, e.g.:
- Set correct configuration directory (high to low priority):
$PRSCTRL_GUI_CONFIG
$XDG_CONFIG_HOME/prsctrl-gui
~/.config/prsctrl-gui
- Set correct cache directory (high to low priority):
$PRSCTRL_GUI_CACHE
$XDG_CACHE_HOME/prsctrl-gui
~/.cache/prsctrl-gui
Loading settings from a file: