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

L2SS-375: archiver bugs fixing

parent 3e910d98
No related branches found
No related tags found
1 merge request!153Resolve L2SS-375 "Archiving load"
...@@ -201,27 +201,28 @@ class Archiver(): ...@@ -201,27 +201,28 @@ class Archiver():
""" """
if (len(attribute_name.split('/'))!=4): if (len(attribute_name.split('/'))!=4):
raise AttributeFormatException raise AttributeFormatException
try: attributes = self.cm.AttributeSearch(attribute_name.lower())
attributes = self.cm.AttributeSearch(attribute_name)
a = [a for a in attributes if a.lower().endswith(attribute_name.lower())] # handle cases differences
if len(attributes)>1: if len(attributes)>1:
raise Exception("MultipleAttributesMatched!") # Handle case same attribute_name r/rw
if len(attributes)==1: if len(attributes)==2 and (attributes[0].endswith(attributes[1]+'w') or attributes[1].endswith(attributes[0]+'w')):
return True
else:
raise Exception(f"Multiple Attributes Matched! {attributes}")
elif len(attributes)==1:
return True return True
else: else:
return False return False
except Exception as e:
raise Exception from e
def update_archiving_attribute(self, attribute_name: str, polling_period: int, event_period: int, strategy: str = 'RUN'): def update_archiving_attribute(self, attribute_name: str, polling_period: int, event_period: int, strategy: str = 'RUN'):
""" """
Update the archiving properties of an attribute already in a subscriber list Update the archiving properties of an attribute already in a subscriber list
""" """
self.remove_attribute_from_archiver(attribute_name) self.remove_attribute_from_archiver(attribute_name)
time.sleep(1) time.sleep(2.)
self.add_attribute_to_archiver(attribute_name,polling_period,event_period,strategy) self.add_attribute_to_archiver(attribute_name,polling_period,event_period,strategy)
time.sleep(1) time.sleep(2.)
self.start_archiving_attribute(attribute_name) self.start_archiving_attribute(attribute_name)
logger.warning(f"Attribute {attribute_name} successfully updated!")
def get_subscriber_attributes(self,es_name:str = None): def get_subscriber_attributes(self,es_name:str = None):
""" """
...@@ -242,13 +243,9 @@ class Archiver(): ...@@ -242,13 +243,9 @@ class Archiver():
es = DeviceProxy(es_name) es = DeviceProxy(es_name)
else: else:
es = self.es es = self.es
try:
attrs = es.AttributeList or [] attrs = es.AttributeList or []
errs = es.AttributeErrorList or [] errs = es.AttributeErrorList or []
return dict((a,e) for a,e in zip(attrs,errs) if e) return dict((a,e) for a,e in zip(attrs,errs) if e) or {}
except:
print('No attribute errors in the subscriber')
return {}
def get_attribute_errors(self,attribute_name:str): def get_attribute_errors(self,attribute_name:str):
""" """
...@@ -285,7 +282,7 @@ class Archiver(): ...@@ -285,7 +282,7 @@ class Archiver():
if self.is_attribute_archived(attribute_name): if self.is_attribute_archived(attribute_name):
freq_dict = dict((a,r) for a,r in zip(self.es.AttributeList,self.es.AttributeRecordFreqList)) freq_dict = dict((a,r) for a,r in zip(self.es.AttributeList,self.es.AttributeRecordFreqList))
for f in freq_dict: for f in freq_dict:
if attribute_name in f: if attribute_name.lower() in f:
return freq_dict.get(f,0.) return freq_dict.get(f,0.)
else: else:
logger.warning(f"Attribute {attribute_name} not found!") logger.warning(f"Attribute {attribute_name} not found!")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment