From 87eca6f46aab13bc605237c6b9a912082c852c1a Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 5 Oct 2020 17:59:25 +0200 Subject: [PATCH] Raise error if there is a syntax error in stored post-processing scripts Instead of just crashing the entire application. Fixes Sentry issue CURA-19W. --- plugins/PostProcessingPlugin/PostProcessingPlugin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/PostProcessingPlugin/PostProcessingPlugin.py b/plugins/PostProcessingPlugin/PostProcessingPlugin.py index 90f3d26cd6..075f947622 100644 --- a/plugins/PostProcessingPlugin/PostProcessingPlugin.py +++ b/plugins/PostProcessingPlugin/PostProcessingPlugin.py @@ -261,7 +261,11 @@ class PostProcessingPlugin(QObject, Extension): script_str = script_str.replace(r"\\\n", "\n").replace(r"\\\\", "\\\\") # Unescape escape sequences. script_parser = configparser.ConfigParser(interpolation=None) script_parser.optionxform = str # type: ignore # Don't transform the setting keys as they are case-sensitive. - script_parser.read_string(script_str) + try: + script_parser.read_string(script_str) + except configparser.Error as e: + Logger.error("Stored post-processing scripts have syntax errors: {err}".format(err = str(e))) + continue for script_name, settings in script_parser.items(): # There should only be one, really! Otherwise we can't guarantee the order or allow multiple uses of the same script. if script_name == "DEFAULT": # ConfigParser always has a DEFAULT section, but we don't fill it. Ignore this one. continue