From 1e340c706512162741dc4b7d280ee407a5ee33cb Mon Sep 17 00:00:00 2001 From: sepro Date: Wed, 19 Jul 2017 09:56:32 +0200 Subject: [PATCH] added try-except (as non-null exit codes raise errors) --- cluster/__init__.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cluster/__init__.py b/cluster/__init__.py index 6af5a66..48e0cac 100644 --- a/cluster/__init__.py +++ b/cluster/__init__.py @@ -12,15 +12,21 @@ def detect_cluster_system(): :return: string "SBE", "PBS" or "other" """ - which_output = check_output(["which", "sge_qmaster"]).decode("utf-8") + try: + which_output = check_output(["which", "sge_qmaster"]).decode("utf-8") - if "/sge_qmaster" in which_output: - return "SGE" + if "/sge_qmaster" in which_output: + return "SGE" + except Exception as _: + pass - which_output = check_output(["which", "pbs_sched"]).decode("utf-8") + try: + which_output = check_output(["which", "pbs_sched"]).decode("utf-8") - if "/pbs_sched" in which_output: - return "PBS" + if "/pbs_sched" in which_output: + return "PBS" + except Exception as _: + pass return "other"