From 088f3d8f75328070e825672493692854f892b368 Mon Sep 17 00:00:00 2001 From: Mikkel Schmidt Date: Sat, 21 Dec 2024 01:17:42 +0100 Subject: [PATCH] Extras: more work on post-processor --- configuration/klippy/ratos.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/configuration/klippy/ratos.py b/configuration/klippy/ratos.py index 68efd5234..15442765c 100644 --- a/configuration/klippy/ratos.py +++ b/configuration/klippy/ratos.py @@ -34,6 +34,7 @@ def __init__(self, config): self.register_commands() self.register_handler() self.load_settings() + self.post_process_success = False ##### # Handler @@ -292,7 +293,6 @@ def process_gcode_file(self, filename, enable_gcode_transform): self.partial_output = "" reactor = self.printer.get_reactor() - success = False def _interpret_output(data): # Handle the parsed data if data['result'] == 'error' and 'message' in data: @@ -347,7 +347,7 @@ def _interpret_output(data): f'_N_Used tools: T{", T".join(analysis_result["usedTools"])}' if "usedTools" in analysis_result else "" + f'_N_Toolshifts: {analysis_result["toolChangeCount"]}' if "toolChangeCount" in analysis_result else "" ) - success = True + self.post_process_success = True return True if data['result'] == 'progress': @@ -405,6 +405,7 @@ def _process_output(eventtime): # Skip lines that aren't valid JSON logging.warning("RatOS postprocessor: Invalid JSON line: " + line) + self.post_process_success = False # Register file descriptor with reactor hdl = reactor.register_fd(process.stdout.fileno(), _process_output) @@ -431,17 +432,18 @@ def _process_output(eventtime): error = process.stderr.read().decode().strip() if error: logging.error(error) - + + self.post_process_success = False return False; - self.console_echo("Post-processing status", "info", "Success: %s" % (success)) + self.console_echo("Post-processing status", "info", "Success: %s" % (self.post_process_success)) - return success; + return self.post_process_success; except Exception as e: raise - return success; + return self.post_process_success; def get_gcode_file_info(self, filename):