diff --git a/utils/venv-manager.py b/utils/venv-manager.py index fbf01e6..5f484f5 100644 --- a/utils/venv-manager.py +++ b/utils/venv-manager.py @@ -69,7 +69,7 @@ def get_args() -> argparse.Namespace: return parser.parse_args() -def run_logged_subprocess(command: Union[str, list], timeout: int = 10, shell: bool = False) -> list: +def run_logged_subprocess(command: Union[str, list], timeout: int = 10, shell: bool = True) -> tuple: """Executes a shell command using subprocess with logging. stderr is redirected to stdout and stdout is pipped to logger. @@ -78,18 +78,18 @@ def run_logged_subprocess(command: Union[str, list], timeout: int = 10, shell: b Example: Running a successful command: run_logged_subprocess(command=["git", "commit", "-m", "'Commit message.'"]) - Returns: {"returncode": 0, "output": []} + Returns: (0, "") Running an unsuccessful shell command with a 20 second timeout: run_logged_subprocess(command="cd test/", timeout=20, shell=True) - Returns: {"returncode": 1, "output": ["cd: test: No such file or directory"]} + Returns: (1, "cd: test: No such file or directory\n") Args: command (Union): The command to run. If shell=False, pass a list with the first item being the command and the subsequent items being arguments. If shell=True, pass a string as you would type it into a shell. timeout (int): The number of seconds to wait for a program before killing it Returns: - dict: Containing subprocess return code and output. + tuple: With the first value being the return code and second being the combined stdout+stderr """ logger.debug(f"Entering subprocess for '{command}'") with subprocess.Popen(command,\ @@ -116,7 +116,7 @@ def run_logged_subprocess(command: Union[str, list], timeout: int = 10, shell: b logger.debug(f"Subprocess for '{command}' completed successfuly") finally: logger.debug(f"Exiting subprocess for '{command}'") - return {"returncode": logged_shell_process.returncode, "output": process_output_lines} + return (logged_shell_process.returncode, process_output_stream)