From 775cbf5a1b255b8d1ab865682d74b4851e624c6c Mon Sep 17 00:00:00 2001 From: Arjan Draisma Date: Mon, 15 Jul 2024 13:07:08 +0200 Subject: [PATCH] rework return codes and exceptions --- src/nplinker/genomics/bigscape/runbigscape.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/nplinker/genomics/bigscape/runbigscape.py b/src/nplinker/genomics/bigscape/runbigscape.py index ee63e9a0..3c2a764a 100644 --- a/src/nplinker/genomics/bigscape/runbigscape.py +++ b/src/nplinker/genomics/bigscape/runbigscape.py @@ -83,9 +83,13 @@ def run_bigscape( logger.info(f"BiG-SCAPE command: {args}") result = subprocess.run(args, stdout=sys.stdout, stderr=sys.stderr, check=True) logger.info(f"BiG-SCAPE completed with return code {result.returncode}") - # use subprocess.CompletedProcess.check_returncode() to test if the BiG-SCAPE - # process exited successfully. This throws an exception for non-zero returncodes - # which will indicate to the PODPDownloader module that something went wrong. - result.check_returncode() - return True + # return true on any non-error return code + if result.returncode == 0: + return True + + # otherwise log details and raise a runtime error + logger.error(f"BiG-SCAPE failed with return code {result.returncode}") + logger.error(f"output: {result.stdout}") + + raise RuntimeError(f"Failed to run BiG-SCAPE with error code {result.returncode}")