From 0f930e66aa81a9065bc9154aa27fad439a87f67f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Diot?= Date: Wed, 20 Nov 2024 12:33:47 +0100 Subject: [PATCH] fix: add DATABASE_URI to environment variables in CLI command execution --- src/common/cli/CLI.py | 2 +- src/common/cli/main.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/common/cli/CLI.py b/src/common/cli/CLI.py index 8c3ececff..775c7e3e3 100644 --- a/src/common/cli/CLI.py +++ b/src/common/cli/CLI.py @@ -307,7 +307,7 @@ class CLI(ApiCaller): cmd.extend(args) self.__logger.debug(f"Executing command {' '.join(cmd)}") - proc = run(cmd, stdin=DEVNULL, stderr=STDOUT, check=False, env=self.__variables | environ | ({"LOG_LEVEL": "DEBUG"} if debug else {})) # type: ignore + proc = run(cmd, stdin=DEVNULL, stderr=STDOUT, check=False, env=self.__variables | environ | ({"LOG_LEVEL": "DEBUG"} if debug else {}) | ({"DATABASE_URI": self.__db.database_uri} if self.__db else {})) # type: ignore if proc.returncode != 0: return False, f"Command {command} failed" diff --git a/src/common/cli/main.py b/src/common/cli/main.py index f1ec7f02d..69f48793e 100644 --- a/src/common/cli/main.py +++ b/src/common/cli/main.py @@ -60,6 +60,9 @@ if __name__ == "__main__": # Parse args args = parser.parse_args() + if args.debug: + logger.setLevel("DEBUG") + # Instantiate CLI cli = CLI()