Skip to content

Commit

Permalink
Extras: more work on post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
miklschmidt committed Dec 21, 2024
1 parent 1099066 commit 088f3d8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions configuration/klippy/ratos.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(self, config):
self.register_commands()
self.register_handler()
self.load_settings()
self.post_process_success = False

#####
# Handler
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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':
Expand Down Expand Up @@ -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)

Expand All @@ -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):
Expand Down

0 comments on commit 088f3d8

Please sign in to comment.