From 88f83bcf316ef96c9027ab854860111a0da3aefa Mon Sep 17 00:00:00 2001 From: Michael Reuscher <michael.reuscher@desy.de> Date: Thu, 13 Jul 2023 10:24:31 +0200 Subject: [PATCH] to simrunner add output for returncode and errors --- simrunner/data_config.json | 1 + simrunner/simrunner.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/simrunner/data_config.json b/simrunner/data_config.json index ef75128..1e6e445 100644 --- a/simrunner/data_config.json +++ b/simrunner/data_config.json @@ -7,6 +7,7 @@ "-N": "4"}, "data_set_2":{ "--posixDataDir": "protokoll", + "-q": "20", "-n": "20", "-s": "1M", "-i": "0.1s", diff --git a/simrunner/simrunner.py b/simrunner/simrunner.py index 4e58abe..2ecd09a 100644 --- a/simrunner/simrunner.py +++ b/simrunner/simrunner.py @@ -12,8 +12,10 @@ def read_config(): def start_process(program_path, arguments): command = [program_path] + arguments - process = subprocess.run(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE) - return process + result = subprocess.run(command, capture_output=True, text=True) + output = result.stdout + errors = result.stderr + return output, errors, result.returncode def set_arguments(data_config): @@ -38,8 +40,11 @@ def run_sim(e_list, d_path, s_path): os.makedirs(relativ_path, mode=0o777, exist_ok=True) event[-1] = relativ_path arguments = event - output = start_process(s_path, arguments) + output, errors, return_code = start_process(s_path, arguments) print(output) + print(errors) + if return_code > 0: + print(return_code) # --- MAIN --- -- GitLab