diff --git a/devices/APSCTL.py b/devices/APSCTL.py index 0cb322251d66d5f21f737ce9d1f3034dafd802a0..fe66a52a1dbe1f0bbb2b7f5ae931e1a7d4f338c1 100644 --- a/devices/APSCTL.py +++ b/devices/APSCTL.py @@ -149,9 +149,11 @@ class APSCTL(hardware_device): @log_exceptions() def configure_for_off(self): """ user code here. is called when the state is set to OFF """ - # Stop keep-alive - self.opcua_connection.stop() + try: + self.opcua_connection.stop() + except Exception as e: + self.error_stream("Caught this exception when going to OFF state:".format(e)) @log_exceptions() def configure_for_initialise(self): @@ -165,10 +167,10 @@ class APSCTL(hardware_device): for i in self.attr_list(): try: i.set_comm_client(self.OPCua_client) - except: + except Exception as e: # use the pass function instead of setting read/write fails i.set_pass_func() - self.error_stream("error in getting APSCTL attribute: {} from client".format(i)) + self.warn_stream("error while setting the APSCTL attribute {} read/write function. {}".format(i, e)) self.OPCua_client.start() diff --git a/devices/PCC.py b/devices/PCC.py index da615d180061cbb3704b1322d99e1134b9ebb234..a8c104a3e400253ada5279078065f13994ac3cf4 100644 --- a/devices/PCC.py +++ b/devices/PCC.py @@ -120,7 +120,10 @@ class PCC(hardware_device): def configure_for_off(self): """ user code here. is called when the state is set to OFF """ # Stop keep-alive - self.OPCua_client.stop() + try: + self.opcua_connection.stop() + except Exception as e: + self.error_stream("Caught this exception when going to OFF state:".format(e)) @log_exceptions() def configure_for_initialise(self): @@ -144,10 +147,10 @@ class PCC(hardware_device): for i in self.attr_list(): try: i.set_comm_client(self.OPCua_client) - except: + except Exception as e: # use the pass function instead of setting read/write fails i.set_pass_func() - self.error_stream("error in getting PCC attribute: {} from client".format(i)) + self.warn_stream("error while setting the PCC attribute {} read/write function. {}".format(i, e)) self.OPCua_client.start() diff --git a/devices/SDP.py b/devices/SDP.py index ebe6809998419e31ca0864e69b96ab2b4160faf1..f8b16bd46b96be1bc7e4edc7f0e2b1b08173ce1a 100644 --- a/devices/SDP.py +++ b/devices/SDP.py @@ -124,7 +124,10 @@ class SDP(hardware_device): """ user code here. is called when the state is set to OFF """ # Stop keep-alive - self.opcua_connection.stop() + try: + self.opcua_connection.stop() + except Exception as e: + self.error_stream("Caught this exception when going to OFF state:".format(e)) @log_exceptions() def configure_for_initialise(self): @@ -138,10 +141,10 @@ class SDP(hardware_device): for i in self.attr_list(): try: i.set_comm_client(self.OPCua_client) - except: + except Exception as e: # use the pass function instead of setting read/write fails i.set_pass_func() - self.debug_stream("error in getting SDP attribute: {} from client".format(i)) + self.warn_stream("error while setting the SDP attribute {} read/write function. {}".format(i, e)) pass self.OPCua_client.start() diff --git a/devices/SNMP.py b/devices/SNMP.py index 078ca6ddf69e237c9aa8c3bc282be3f87c50ef23..db748639ef3c784792b0d5e2211019b50bac1e9f 100644 --- a/devices/SNMP.py +++ b/devices/SNMP.py @@ -92,10 +92,10 @@ class SNMP(hardware_device): for i in self.attr_list(): try: i.set_comm_client(self.snmp_manager) - except: + except Exception as e: # use the pass function instead of setting read/write fails i.set_pass_func() - self.error_stream("error in getting SNMP attribute: {} from client".format(i)) + self.warn_stream("error while setting the SNMP attribute {} read/write function. {}".format(i, e)) self.snmp_manager.start() diff --git a/devices/ini_device.py b/devices/ini_device.py index 9b3e83a1e41e25a775c3b509fff483c5e0ccdafc..dbc6e6159409449cfa7f5577e06eaa84e0620a06 100644 --- a/devices/ini_device.py +++ b/devices/ini_device.py @@ -110,10 +110,11 @@ class ini_device(hardware_device): for i in self.attr_list(): try: i.set_comm_client(self.ini_client) - except: + except Exception as e: # use the pass function instead of setting read/write fails i.set_pass_func() - self.error_stream("error in getting ini attribute: {} from client".format(i)) + + self.warn_stream("error while setting the ini attribute {} read/write function. {}".format(i, e)) self.ini_client.start() diff --git a/devices/util/attribute_wrapper.py b/devices/util/attribute_wrapper.py index 8340af6144c05bf56d60b4d1464ccf3d75278aac..d4584f01b78b22d0ee634d91963d2b80adcd29f4 100644 --- a/devices/util/attribute_wrapper.py +++ b/devices/util/attribute_wrapper.py @@ -136,7 +136,7 @@ class attribute_wrapper(attribute): self.read_function, self.write_function = client.setup_attribute(self.comms_annotation, self) except Exception as e: - logger.error("Exception while setting {} attribute with annotation: '{}'".format(client.__class__.__name__, self.comms_annotation)) + logger.error("Exception while setting {} attribute with annotation: '{}' {}".format(client.__class__.__name__, self.comms_annotation, e)) raise Exception("Exception while setting %s attribute with annotation: '%s'", client.__class__.__name__, self.comms_annotation) from e def set_pass_func(self):