From ca9bbb0b7dd0f252d6d0de199965f4d9a03f6e4f Mon Sep 17 00:00:00 2001 From: Kyle Gabriel Date: Tue, 21 Nov 2023 22:51:34 -0500 Subject: [PATCH] Add try/except for each action --- mycodo/utils/actions.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/mycodo/utils/actions.py b/mycodo/utils/actions.py index c81557e6a..bee9d52f2 100644 --- a/mycodo/utils/actions.py +++ b/mycodo/utils/actions.py @@ -346,19 +346,23 @@ def run_input_actions(unique_id, message, measurements_dict, debug=False): control = DaemonControl() actions = db_retrieve_table_daemon(Actions).filter( Actions.function_id == unique_id).all() - for each_action in actions: - return_dict = control.trigger_action( - each_action.unique_id, - value={"message": message, "measurements_dict": measurements_dict}, - debug=debug) - - # if message is returned, set message - if return_dict and 'message' in return_dict and return_dict['message']: - message = return_dict['message'] - # if measurements_dict is returned, use that to store measurements - if return_dict and 'measurements_dict' in return_dict and return_dict['measurements_dict']: - measurements_dict = return_dict['measurements_dict'] + for each_action in actions: + try: + return_dict = control.trigger_action( + each_action.unique_id, + value={"message": message, "measurements_dict": measurements_dict}, + debug=debug) + + # if message is returned, set message + if return_dict and 'message' in return_dict and return_dict['message']: + message = return_dict['message'] + + # if measurements_dict is returned, use that to store measurements + if return_dict and 'measurements_dict' in return_dict and return_dict['measurements_dict']: + measurements_dict = return_dict['measurements_dict'] + except: + logger.exception(f"Running Input Action {each_action.unique_id}") return message, measurements_dict