From e3bf92b4639d43eea84e6a27190fb3052815105b Mon Sep 17 00:00:00 2001 From: thelastWallE <12502210+thelastWallE@users.noreply.github.com> Date: Mon, 26 Apr 2021 02:25:12 +0200 Subject: [PATCH] check values for xyz offsets --- octoprint_klipper/__init__.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/octoprint_klipper/__init__.py b/octoprint_klipper/__init__.py index 2cf6e42..f172ad4 100644 --- a/octoprint_klipper/__init__.py +++ b/octoprint_klipper/__init__.py @@ -568,6 +568,30 @@ class KlipperPlugin( dataToValidated.readfp(buf) else: dataToValidated.read_string(dataToBeValidated) + + sections_search_list = ["bltouch", + "probe"] + value_search_list = [ "x_offset", + "y_offset", + "z_offset"] + try: + # cycle through sections and then values + for y in sections_search_list: + for x in value_search_list: + if dataToValidated.has_option(y, x): + a_float = dataToValidated.getfloat(y, x) + except ValueError as error: + self.log_error( + "Error: Invalid Value for "+x+" in Section: "+y+"\n" + + "{}".format(str(error)) + ) + self.send_message("PopUp", "warning", "OctoKlipper: Invalid Config\n", + "Config got not saved!\n" + + "You can reload your last changes\n" + + "on the 'Klipper Configuration' tab.\n\n" + + "Invalid Value for "+x+" in Section: "+y+"\n" + "{}".format(str(error))) + self._parsing_check_response = False + return False except configparser.Error as error: if sys.version_info[0] < 3: error.message = error.message.replace("\\n","") @@ -588,9 +612,10 @@ class KlipperPlugin( "You can reload your last changes\n" + "on the 'Klipper Configuration' tab.\n\n" + str(error)) self._parsing_check_response = False + return False else: self._parsing_check_response = True - return + return True #incorrectlines = [] # for section in dataToValidated.sections():