From 6045063476ba5cee692c0309b3a95d53eeaf1def Mon Sep 17 00:00:00 2001 From: Mauro Mugnaini Date: Mon, 17 Apr 2023 17:32:47 +0200 Subject: [PATCH] Logger is now configured correctly via file, requested operation is now logged at `info` --- PyExec.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/PyExec.py b/PyExec.py index 0aaabd5..3db591e 100644 --- a/PyExec.py +++ b/PyExec.py @@ -34,14 +34,20 @@ class PyExec(): self.cfg = configparser.ConfigParser() self.cfg.read(config) self.workerid = self.cfg["common"].get("workerid", "pythonworker-" + str(random.randint(1000,10000))) - logging.config.fileConfig(self.cfg["common"].get("loggerconfig", "logging-docker.cfg")) + loggerconfigfile = self.cfg["common"].get("loggerconfig", "logging-docker.cfg") + print("Loading logger configuration from: " + loggerconfigfile) + logging.config.fileConfig(loggerconfigfile, disable_existing_loggers=False) self.logger = logging.getLogger("pyexec") self.logger.info("Initializing PyExec worker %s with config.cfg", self.workerid) - self.threads = self.cfg["common"].getint("threads", 3) self.pollrate = self.cfg["common"].getfloat("pollrate", .1) self.server = os.environ.get('CONDUCTOR_SERVER', self.cfg["common"].get("server", "http://localhost:8080/api")) self.auth = os.environ.get('CONDUCTOR_WORKER_AUTH', self.cfg["common"].get("auth")) + # if self.auth is None: + # error = "Unable to find auth details neither in ENV nor in config file" + # self.logger.critical(error) + # raise Exception(error) + for plg in pluginlist: path = "pyexecplugins." + plg try: @@ -80,7 +86,7 @@ class PyExec(): # Get operation from input or task type (in case of standalone tasks) fallback to Nop operation = task["inputData"].get("operation") or task["taskDefName"] or "Nop" - self.logger.debug("Operation is %s", operation) + self.logger.info("Operation is %s", operation) # Get plugin by checking either name or alias (in case of standalone tasks the task type is aliased to the plugin name) p = PyExecPlugin.get(operation) or PyExecPlugin.getAlias(operation) @@ -89,7 +95,6 @@ class PyExec(): if p != None: pi = p(task["inputData"], self.cfg) ret = pi.execute() - else: raise Exception("Operation {} not found.".format(operation)) return { "status" : "COMPLETED", "output" : ret, "logs" : ["one","two"]}