From 74af7abf9b271fc06500be8dae0e830d5e64bd7a Mon Sep 17 00:00:00 2001 From: Thomas Kluyver <thomas@kluyver.me.uk> Date: Thu, 9 Jul 2020 13:50:01 +0100 Subject: [PATCH] Exit status 1 if detector or calibration type not found --- xfel_calibrate/calibrate.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/xfel_calibrate/calibrate.py b/xfel_calibrate/calibrate.py index cbf232b9d..e7c6c7b88 100755 --- a/xfel_calibrate/calibrate.py +++ b/xfel_calibrate/calibrate.py @@ -774,23 +774,24 @@ def run(): print("Not running on cluster") try: - pre_notebooks = notebooks[detector][caltype].get("pre_notebooks", []) - notebook = notebooks[detector][caltype]["notebook"] - dep_notebooks = notebooks[detector][caltype].get("dep_notebooks", []) - notebook_path = os.path.join(PKG_DIR, notebook) - concurrency = notebooks[detector][caltype].get("concurrency", None) - + nb_info = notebooks[detector][caltype] except KeyError: print("Not one of the known calibrations or detectors") - return + return 1 + + pre_notebooks = nb_info.get("pre_notebooks", []) + notebook = nb_info["notebook"] + dep_notebooks = nb_info.get("dep_notebooks", []) + concurrency = nb_info.get("concurrency", None) if args["concurrency_par"] is not None: concurrency["parameter"] = args["concurrency_par"] + notebook_path = os.path.join(PKG_DIR, notebook) nb = nbformat.read(notebook_path, as_version=4) # extend parameters if needed - ext_func = notebooks[detector][caltype].get("extend parms", None) + ext_func = nb_info.get("extend parms", None) if ext_func is not None: func = get_notebook_function(nb, ext_func) @@ -1001,4 +1002,4 @@ def run(): if __name__ == "__main__": - run() + sys.exit(run()) -- GitLab