From 1fdeb2adebb8c4de5f5e7ada9cbc5c597d7daff9 Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Fri, 18 Oct 2024 13:26:17 +0200 Subject: [PATCH] refs #986 use logger.debug --- linux/debian/changelog | 6 ++++++ src/OGAgentUser.py | 21 ++++++++----------- src/VERSION | 2 +- src/opengnsys/httpserver.py | 10 ++++----- .../modules/server/OpenGnSys/__init__.py | 4 ++-- 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/linux/debian/changelog b/linux/debian/changelog index 9af7c55..c57a8a4 100644 --- a/linux/debian/changelog +++ b/linux/debian/changelog @@ -1,3 +1,9 @@ +ogagent (1.4.4-1) stable; urgency=medium + + * Use logger.debug() to prevent the windows agent from dying + + -- OpenGnsys developers Thu, 17 Oct 2024 19:13:58 +0200 + ogagent (1.4.3-1) stable; urgency=medium * Use new OGBrowser diff --git a/src/OGAgentUser.py b/src/OGAgentUser.py index 3494d81..a390a35 100755 --- a/src/OGAgentUser.py +++ b/src/OGAgentUser.py @@ -210,7 +210,7 @@ class OGASystemTray(QtWidgets.QSystemTrayIcon): valid_mods.append(mod) except Exception as e: logger.exception() - logger.error("Activation of {} failed: {}".format(mod.name, utils.exceptionToMessage(e))) + logger.debug ("Activation of {} failed: {}".format(mod.name, utils.exceptionToMessage(e))) self.modules[:] = valid_mods # copy instead of assignment # If this is running, it's because he have logged in, inform service of this fact self.ipc.sendLogin((operations.getCurrentUser(), operations.getSessionLanguage(), @@ -223,7 +223,7 @@ class OGASystemTray(QtWidgets.QSystemTrayIcon): mod.deactivate() except Exception as e: logger.exception() - logger.error("Deactivation of {} failed: {}".format(mod.name, utils.exceptionToMessage(e))) + logger.debug ("Deactivation of {} failed: {}".format(mod.name, utils.exceptionToMessage(e))) def timerFnc(self): pass @@ -236,7 +236,7 @@ class OGASystemTray(QtWidgets.QSystemTrayIcon): logger.debug('msg: {}, {}'.format(type(msg), msg)) module, message, data = msg except Exception as e: - logger.error('Got exception {} processing message {}'.format(e, msg)) + logger.debug ('Got exception {} processing message {}'.format(e, msg)) return for v in self.modules: @@ -246,9 +246,9 @@ class OGASystemTray(QtWidgets.QSystemTrayIcon): v.processMessage(message, json.loads(data)) return except Exception as e: - logger.error('Got exception {} processing generic message on {}'.format(e, v.name)) + logger.debug ('Got exception {} processing generic message on {}'.format(e, v.name)) - logger.error('Module {} not found, messsage {} not sent'.format(module, message)) + logger.debug ('Module {} not found, messsage {} not sent'.format(module, message)) ## when is this run?? def executeScript(self, script): @@ -271,7 +271,7 @@ class OGASystemTray(QtWidgets.QSystemTrayIcon): self.deinitialize() except Exception: logger.exception() - logger.error('Got exception deinitializing modules') + logger.debug ('Got exception deinitializing modules') try: # If we close Client, send Logoff to Broker @@ -282,10 +282,7 @@ class OGASystemTray(QtWidgets.QSystemTrayIcon): except Exception: # May we have lost connection with server, simply log and exit in that case logger.exception() - # File "/home/nati/Downloads/work/opengnsys/ogagent/src/OGAgentUser.py", line 286, in cleanup - # logger.exception("Got an exception, processing quit") - #TypeError: Logger.exception() takes 1 positional argument but 2 were given - #logger.exception("Got an exception, processing quit") + logger.debug ('Got an exception, processing quit') try: # operations.logoff() # Uncomment this after testing to logoff user @@ -319,7 +316,7 @@ if __name__ == '__main__': trayIcon = OGASystemTray(app) except Exception as e: logger.exception() - logger.error('OGA Service is not running, or it can\'t contact with OGA Server. User Tools stopped: {}'.format( + logger.debug ('OGA Service is not running, or it can\'t contact with OGA Server. User Tools stopped: {}'.format( utils.exceptionToMessage(e))) sys.exit(1) @@ -327,7 +324,7 @@ if __name__ == '__main__': trayIcon.initialize() # Initialize modules, etc.. except Exception as e: logger.exception() - logger.error('Exception initializing OpenGnsys User Agent {}'.format(utils.exceptionToMessage(e))) + logger.debug ('Exception initializing OpenGnsys User Agent {}'.format(utils.exceptionToMessage(e))) trayIcon.quit() sys.exit(1) diff --git a/src/VERSION b/src/VERSION index 428b770..1c99cf0 100644 --- a/src/VERSION +++ b/src/VERSION @@ -1 +1 @@ -1.4.3 +1.4.4 diff --git a/src/opengnsys/httpserver.py b/src/opengnsys/httpserver.py index bcbb238..e2b8be2 100644 --- a/src/opengnsys/httpserver.py +++ b/src/opengnsys/httpserver.py @@ -96,22 +96,22 @@ class HTTPServerHandler(BaseHTTPRequestHandler): logger.exception() n_args = len (e.args) if 0 == n_args: - logger.error ('Empty exception raised from message processor for "{}"'.format(path[0])) + logger.debug ('Empty exception raised from message processor for "{}"'.format(path[0])) self.sendJsonError(500, exceptionToMessage(e)) else: arg0 = e.args[0] if type (arg0) is str: - logger.error ('Message processor for "{}" returned exception string "{}"'.format(path[0], str(e))) + logger.debug ('Message processor for "{}" returned exception string "{}"'.format(path[0], str(e))) self.sendJsonError (500, exceptionToMessage(e)) elif type (arg0) is dict: if '_httpcode' in arg0: - logger.warning ('Message processor for "{}" returned HTTP code "{}" with exception string "{}"'.format(path[0], str(arg0['_httpcode']), str(arg0['_msg']))) + logger.debug ('Message processor for "{}" returned HTTP code "{}" with exception string "{}"'.format(path[0], str(arg0['_httpcode']), str(arg0['_msg']))) self.sendJsonError (arg0['_httpcode'], arg0['_msg']) else: - logger.error ('Message processor for "{}" returned exception dict "{}" with no HTTP code'.format(path[0], str(e))) + logger.debug ('Message processor for "{}" returned exception dict "{}" with no HTTP code'.format(path[0], str(e))) self.sendJsonError (500, exceptionToMessage(e)) else: - logger.error ('Message processor for "{}" returned non-string and non-dict exception "{}"'.format(path[0], str(e))) + logger.debug ('Message processor for "{}" returned non-string and non-dict exception "{}", type "{}"'.format(path[0], str(e), type(e))) self.sendJsonError (500, exceptionToMessage(e)) ## not reached diff --git a/src/opengnsys/modules/server/OpenGnSys/__init__.py b/src/opengnsys/modules/server/OpenGnSys/__init__.py index d152306..259544a 100644 --- a/src/opengnsys/modules/server/OpenGnSys/__init__.py +++ b/src/opengnsys/modules/server/OpenGnSys/__init__.py @@ -65,7 +65,7 @@ def check_secret(fnc): else: raise Exception('Unauthorized operation') except Exception as e: - logger.error(str(e)) + logger.debug (str(e)) raise Exception(e) return wrapper @@ -83,7 +83,7 @@ def execution_level(level): else: raise Exception('Unauthorized operation') except Exception as e: - logger.error(str(e)) + logger.debug (str(e)) raise Exception(e) return wrapper