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

L2SS-405: replace infixes with regex

parent 6e8246c3
No related branches found
No related tags found
1 merge request!265Resolve L2SS-405 "Archiving setup production"
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
"event_period": "60000", "event_period": "60000",
"strategy": "RUN", "strategy": "RUN",
"infixes":[ "infixes":[
{"attribute": "IOUT", "archive_period": "60000", "event_period": "1000", "abs_change": null, "rel_change": 5}, {"attribute": "/*IOUT*", "archive_period": "60000", "event_period": "1000", "abs_change": null, "rel_change": 5},
{"attribute": "VOUT", "archive_period": "60000", "event_period": "1000", "abs_change": null, "rel_change": 5}, {"attribute": "/*VOUT*", "archive_period": "60000", "event_period": "1000", "abs_change": null, "rel_change": 5},
{"attribute": "TEMP", "archive_period": "60000", "event_period": "1000", "abs_change": 0.5, "rel_change": 5} {"attribute": "/*TEMP*", "archive_period": "60000", "event_period": "1000", "abs_change": 0.5, "rel_change": 5}
], ],
"suffixes":[ "suffixes":[
{"attribute": "_error_R", "archive_period": "60000", "event_period": "1000", "abs_change": "1", "rel_change": null}, {"attribute": "_error_R", "archive_period": "60000", "event_period": "1000", "abs_change": "1", "rel_change": null},
......
...@@ -6,6 +6,7 @@ Functions related to the managing of the archiver configuration JSON file ...@@ -6,6 +6,7 @@ Functions related to the managing of the archiver configuration JSON file
""" """
import logging import logging
import re
from tangostationcontrol.toolkit.archiver_util import get_attributes_from_suffix, retrieve_attributes_from_wildcards from tangostationcontrol.toolkit.archiver_util import get_attributes_from_suffix, retrieve_attributes_from_wildcards
logger = logging.getLogger() logger = logging.getLogger()
...@@ -35,7 +36,8 @@ def get_parameters_from_attribute(device_name:str, attribute_name:str, config_di ...@@ -35,7 +36,8 @@ def get_parameters_from_attribute(device_name:str, attribute_name:str, config_di
# Search if the archiving parameters are listed inside the global infixes attributes # Search if the archiving parameters are listed inside the global infixes attributes
infixes = config_dict['_global_variables'][environment]['infixes'] infixes = config_dict['_global_variables'][environment]['infixes']
for a in infixes: for a in infixes:
if a['attribute'].lower() in attribute_name.lower(): # Match regular expression with attribute name
if re.compile(a['attribute'].lower()).search(attribute_name):
return _get_archiving_parameters(a) return _get_archiving_parameters(a)
# Search if the archiving parameters are listed inside the global suffixes attributes # Search if the archiving parameters are listed inside the global suffixes attributes
suffixes = config_dict['_global_variables'][environment]['suffixes'] suffixes = config_dict['_global_variables'][environment]['suffixes']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment