Skip to content

Commit

Permalink
Extras: overwrite input files in new processor, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
miklschmidt committed Nov 3, 2024
1 parent bae7b84 commit 5007bba
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions klippy/ratos.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@ def cmd_TEST_PROCESS_GCODE_FILE(self, gcmd):
dual_carriage = self.dual_carriage
self.dual_carriage = True
filename = gcmd.get('FILENAME', "")
use_new_postprocess = gcmd.get('USE_NEW', "false").lower() == "true"
if filename[0] == '/':
filename = filename[1:]
self.process_gode_file(filename, True)
if use_new_postprocess:
self.process_gcode_file(filename, True)
else:
self.old_postprocess(filename, True)
self.dual_carriage = dual_carriage

desc_HELLO_RATOS = "RatOS mainsail welcome message"
Expand Down Expand Up @@ -156,10 +160,10 @@ def cmd_PROCESS_GCODE_FILE(self, gcmd):
if (self.dual_carriage == None and self.rmmu_hub == None) or not self.enable_post_processing:
self.gcode.run_script_from_command("SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_x VALUE=" + str(-1))
self.gcode.run_script_from_command("SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=first_y VALUE=" + str(-1))
self.process_gode_file(filename, False)
self.old_postprocess(filename, False)
self.v_sd.cmd_SDCARD_PRINT_FILE(gcmd)
else:
if self.process_gode_file(filename, True):
if self.old_postprocess(filename, True):
self.v_sd.cmd_SDCARD_PRINT_FILE(gcmd)
else:
raise self.printer.command_error("Could not process gcode file")
Expand Down Expand Up @@ -213,9 +217,11 @@ def process_gcode_file(self, filename, enable_post_processing):
isIdex = self.config.has_section("dual_carriage")
if isIdex:
args.append('--idex')
if enable_post_processing:
args.append('--overwrite-input')
args.append(filename)
process = subprocess.Popen(
['ratos', 'postprocess', '--non-interactive', filename],
args,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
Expand Down Expand Up @@ -322,7 +328,7 @@ def _process_output(eventtime):
#####
# G-code post processor
#####
def process_gode_file(self, filename, enable_post_processing):
def old_postprocess(self, filename, enable_post_processing):
echo_prefix = "POST_PROCESSOR"
try:
[path, size] = self.get_gcode_file_info(filename)
Expand Down

0 comments on commit 5007bba

Please sign in to comment.