From 44493d16fdff2273c0f395c539bac5bbedf0afdf Mon Sep 17 00:00:00 2001 From: alextrical <35117191+alextrical@users.noreply.github.com> Date: Tue, 13 Feb 2024 20:32:21 +0000 Subject: [PATCH] Run_script echo output to console, and capture errors from script --- bottles/backend/managers/installer.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bottles/backend/managers/installer.py b/bottles/backend/managers/installer.py index a000f21d2b..d4066527d1 100644 --- a/bottles/backend/managers/installer.py +++ b/bottles/backend/managers/installer.py @@ -249,13 +249,18 @@ def __step_run_script(config: BottleConfig, step: dict): return False logging.info(f"Executing installer script…") - subprocess.Popen( + result = subprocess.run( f"bash -c '{script}'", shell=True, cwd=ManagerUtils.get_bottle_path(config), - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - ).communicate() + capture_output=True, + ) + logging.info(f"Output: \n{result.stdout.decode()}\n") + if result.returncode != 0: + # an error happened! + err_msg = "Status: FAIL \nError: %s\nCode: %s" % (result.stderr.decode(), result.returncode) + logging.error(err_msg) + # raise Exception(err_msg) #Raise blocking error logging.info(f"Finished executing installer script.") @staticmethod