From d51d7cd9887d29c83dde5be1436a29849c995c39 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Thu, 5 Sep 2024 09:46:30 +0300 Subject: [PATCH] manage exit code of 'get_image' and 'set_focus' functions --- focus_utils.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/focus_utils.py b/focus_utils.py index 5cc51ad..e8ffeb5 100644 --- a/focus_utils.py +++ b/focus_utils.py @@ -388,13 +388,17 @@ def focussingSequence( executor = ProcessPoolExecutor(max_workers=max_wks) i_foc = 0 + ret_code = 0 for foc_val in focus_value: print(log_ident, file=log_output, end="") print("set focus value to {:g} ...\t".format(foc_val), file=log_output, end="") - set_focus_func(foc_val) - - print("OK", file=log_output) + ret_code = set_focus_func(foc_val) + if ret_code: + print("FAIL!", file=log_output) + break + else: + print("OK", file=log_output) filename = "{}_{:04d}{}".format(fname, i_foc, file_ext) full_filename = pt.Path.joinpath(dir, pt.Path(filename)) @@ -417,11 +421,16 @@ def focussingSequence( print("OK", file=log_output) - fit_res = fitFocusCurve(focus_value, flux_rad, **seq_kwds) + if ret_code == 0: + fit_res = fitFocusCurve(focus_value, flux_rad, **seq_kwds) - ret_val["focus_value"] = fit_res[0] - ret_val["coeffs"] = fit_res[1] - ret_val["is_robust"] = fit_res[2] + ret_val["focus_value"] = fit_res[0] + ret_val["coeffs"] = fit_res[1] + ret_val["is_robust"] = fit_res[2] + else: + print( + "THERE WERE ERRORS DURING FOCUSSING SEQUENCE SO NO BEST FOCUS IS AVAILABLE!!!" + ) return ret_val