diff --git a/devices/toolkit/archiver.py b/devices/toolkit/archiver.py index 9f77bc39efe60ccfc9f94f72d6060fd44dc92e61..e11578dc68d8829cc1e261cd884392cba7f6be88 100644 --- a/devices/toolkit/archiver.py +++ b/devices/toolkit/archiver.py @@ -201,27 +201,28 @@ class Archiver(): """ if (len(attribute_name.split('/'))!=4): raise AttributeFormatException - try: - 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: - raise Exception("MultipleAttributesMatched!") - if len(attributes)==1: + attributes = self.cm.AttributeSearch(attribute_name.lower()) + if len(attributes)>1: + # Handle case same attribute_name r/rw + if len(attributes)==2 and (attributes[0].endswith(attributes[1]+'w') or attributes[1].endswith(attributes[0]+'w')): return True else: - return False - except Exception as e: - raise Exception from e + raise Exception(f"Multiple Attributes Matched! {attributes}") + elif len(attributes)==1: + return True + else: + return False 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 """ 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) - time.sleep(1) + time.sleep(2.) self.start_archiving_attribute(attribute_name) + logger.warning(f"Attribute {attribute_name} successfully updated!") def get_subscriber_attributes(self,es_name:str = None): """ @@ -242,13 +243,9 @@ class Archiver(): es = DeviceProxy(es_name) else: es = self.es - try: - attrs = es.AttributeList or [] - errs = es.AttributeErrorList or [] - return dict((a,e) for a,e in zip(attrs,errs) if e) - except: - print('No attribute errors in the subscriber') - return {} + attrs = es.AttributeList or [] + errs = es.AttributeErrorList or [] + return dict((a,e) for a,e in zip(attrs,errs) if e) or {} def get_attribute_errors(self,attribute_name:str): """ @@ -285,7 +282,7 @@ class Archiver(): if self.is_attribute_archived(attribute_name): freq_dict = dict((a,r) for a,r in zip(self.es.AttributeList,self.es.AttributeRecordFreqList)) for f in freq_dict: - if attribute_name in f: + if attribute_name.lower() in f: return freq_dict.get(f,0.) else: logger.warning(f"Attribute {attribute_name} not found!")