Skip to content
Snippets Groups Projects
Commit a2af8e21 authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

L2SS-405: refine documentation and exception handling

parent 5b1e86a7
Branches
Tags
1 merge request!265Resolve L2SS-405 "Archiving setup production"
......@@ -154,9 +154,11 @@ class Archiver():
# Add the attribute to the archiver setting either specific or global parameters
self.add_attribute_to_archiver(att_fqname, dev_polling_time, archive_period or dev_archive_period, dev_strategy,
abs_change or dev_archive_abs_change, rel_change or dev_archive_rel_change)
except Exception as e:
except DevFailed as e:
if 'already subscribed' in str(e):
logger.warning(f"Multiple entries of Attribute {device}'/'{att} in config file")
else:
raise
def configure_for_production(self, config_dict:dict, device:str):
"""
......@@ -185,9 +187,11 @@ class Archiver():
for att in exclude_att_list:
att_fqname = attribute_fqdn(f"{device}/{att}")
self.remove_attribute_from_archiver(att_fqname)
except Exception as e:
except DevFailed as e:
if 'already subscribed' in str(e):
logger.warning(f"Multiple entries of Attribute {device}'/'{att} in config file")
else:
raise
def add_event_subscriber(self, es_name:str=None):
"""
......
......@@ -2,7 +2,7 @@
"""
Functions related to the managing of archiver configuration JSON file
Functions related to the managing of the archiver configuration JSON file
"""
import logging
......@@ -11,7 +11,9 @@ from tangostationcontrol.toolkit.archiver_util import get_attributes_from_suffix
logger = logging.getLogger()
def _get_archiving_parameters(attribute:str):
"""Helper function that returns four archiving parameters defined in a JSON file"""
"""Helper function that returns the following archiving parameters defined in a JSON file:
archive period [ms], event period [ms], absolute change, relative change
"""
archive_period = int(attribute['archive_period'])
event_period = int(attribute['event_period'])
abs_change = attribute['abs_change'] and int(attribute['abs_change'])
......@@ -20,7 +22,8 @@ def _get_archiving_parameters(attribute:str):
def get_parameters_from_attribute(device_name:str, attribute_name:str, config_dict:dict, environment: str):
"""
Return the archiving parameters defined in the configuration file for a certain attribute
Return the archiving parameters ( see ref.: '_get_archiving_parameters' )
defined in the configuration file for a certain attribute
"""
if environment == 'development':
# Search if the attribute parameters are listed inside the device configuration
......@@ -64,7 +67,9 @@ def get_exclude_attribute_list(device:str, config_dict:dict):
return exclude_att_list
def get_global_env_parameters(config_dict:dict, environment:str):
"""Return the archiving parameters defined in the 'global_variable' section of the JSON configuration file"""
"""Return the following archiving parameters defined in the 'global_variable' section of the JSON configuration file:
polling time [ms], absolute change, relative change, archive period [ms], event period [ms] and strategy
"""
var_dict = config_dict['_global_variables']
# Archiving parameters retrieved from JSON file
polling_time = int(var_dict[environment]['polling_time'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment