From d698c4023f891ead2ba7342535f74dc3e0e7424a Mon Sep 17 00:00:00 2001 From: Luca Date: Mon, 23 Dec 2024 11:11:09 +0100 Subject: [PATCH] extending polarion_config parsing to accept token field --- src/pyMetricCli/polarion.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pyMetricCli/polarion.py b/src/pyMetricCli/polarion.py index f2447fa..e92bd53 100644 --- a/src/pyMetricCli/polarion.py +++ b/src/pyMetricCli/polarion.py @@ -68,7 +68,7 @@ def __run_pypolarioncli(self, arguments) -> subprocess.CompletedProcess: arguments (list): List of arguments to pass to pyPolarionCli. Returns: - subprocess.CompletedProcess[bytes]: The result of the command. + subprocess.CompletedProcess[bytes]: The result of the command. Includes return code, stdout and stderr. """ args = ["pyPolarionCli"] # The executable to run. @@ -109,12 +109,17 @@ def search(self) -> dict: f"{self.config['project']}_search_results.json") command_list: list = ["--user", self.config["username"], - "--password", self.config["password"], - "--server", self.config["server"], - "search", - "--project", self.config["project"], - "--output", self.config["output"], - "--query", self.config["query"]] + "--password", self.config["password"]] + + # Add token if available. pyPolarionCli will use it instead of the password if provided. + if "token" in self.config and self.config["token"]: + command_list += ["--token", self.config["token"]] + + command_list += ["--server", self.config["server"], + "search", + "--project", self.config["project"], + "--output", self.config["output"], + "--query", self.config["query"]] for field in self.config["fields"]: command_list.append("--field")