From 2f50586426832f7f6c45189fbf34955f7ce6f5b3 Mon Sep 17 00:00:00 2001 From: Thomas Juerges <4-jurges@users.noreply.git.astron.nl> Date: Fri, 2 Apr 2021 19:57:45 +0200 Subject: [PATCH] Improve exception formatting and remove unneeded logging --- devices/clients/opcua_connection.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/devices/clients/opcua_connection.py b/devices/clients/opcua_connection.py index 6b4a5b822..c5fa45507 100644 --- a/devices/clients/opcua_connection.py +++ b/devices/clients/opcua_connection.py @@ -90,7 +90,7 @@ class OPCUAConnection(CommClient): try: self.client.disconnect() except Exception as e: - self.streams.error_stream("Disconnect from OPC-UA server %s failed: %s", self._servername(), e) + self.streams.error_stream("Disconnect from OPC-UA server {} failed: {}".format(self._servername(), e)) def ping(self): """ @@ -99,7 +99,7 @@ class OPCUAConnection(CommClient): try: self.client.send_hello() except Exception as e: - raise Exception("Lost connection to server %s: %s", self._servername(), e) + raise Exception("Lost connection to server {}.".format(self._servername())) from e def _setup_annotation(self, annotation): """ @@ -115,13 +115,12 @@ class OPCUAConnection(CommClient): elif isinstance(annotation, list): path = annotation else: - raise Exception("OPC-ua mapping requires either a list of the path or dict with the path. Was given %s type containing: %s", type(annotation), annotation) + raise Exception("OPC-ua mapping requires either a list of the path or dict with the path. Was given {} type containing: {}".format(type(annotation), annotation)) try: node = self.obj.get_child(path) except Exception as e: - self.streams.error_stream("Could not get node: %s on server %s: %s", path, self._servername(), e) - raise Exception("Could not get node: %s on server %s", path, self._servername()) from e + raise Exception("Could not get node: {} on server {}".format(path, self._servername())) from e return node -- GitLab