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

L2SS-659: cleaning code

parent 7c150511
Branches
Tags
1 merge request!273Resolve L2SS-659 "Compute archiving load"
......@@ -239,7 +239,7 @@ class Archiver():
else:
raise
def add_attributes_by_device(self, device_name, global_archive_period:int = None, global_abs_change:int = None,
def add_attributes_by_device(self, device_name, global_archive_period:int = None, global_abs_change:int = 1,
global_rel_change:int = None, es_name:str=None, exclude:list = None):
"""
Add sequentially all the attributes of the selected device in the event subscriber list, if not already present
......@@ -252,18 +252,19 @@ class Archiver():
exclude = []
d = DeviceProxy(device_fqdn(device_name))
dev_attrs_list = d.get_attribute_list()
device_attrs_list = d.get_attribute_list()
# Filter out the attributes in exclude-list
exclude_list = [a.lower() for a in exclude]
attrs_list = [a.lower() for a in list(dev_attrs_list) if a.lower() not in exclude_list] # transform list for string comparison
attrs_list = [a.lower() for a in list(device_attrs_list) if a.lower() not in exclude_list] # transform list for string comparison
for a in attrs_list:
attr_fullname = attribute_fqdn(f"{device_name}/{a}")
attr_proxy = AttributeProxy(attr_fullname)
if attr_proxy.is_polled() and not self.is_attribute_archived(attr_fullname): # if not polled attribute is also not archived
if attr_proxy.is_polled() and not self.is_attribute_archived(attr_fullname): # if not polled, attribute is also not archived
try:
es = DeviceProxy(es_name or self.get_next_subscriber()) # choose an e.s. or get the first one available
polling_period = attr_proxy.get_poll_period() or self.dev_polling_time
archive_period = global_archive_period or int(attr_proxy.get_property('archive_period')['archive_period'][0]) or self.dev_archive_period
abs_change = global_abs_change or 1
polling_period = attr_proxy.get_poll_period() or self.prod_polling_time
archive_period = global_archive_period or int(attr_proxy.get_property('archive_period')['archive_period'][0])
abs_change = global_abs_change
rel_change = global_rel_change
self.add_attribute_to_archiver(attr_fullname,polling_period=polling_period,
archive_event_period = archive_period, abs_change=abs_change, rel_change=rel_change, es_name = es.name())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment