0.1.8rc7
* update pybambu module from upstream HA project, groundwork for fixing new cloud authorization process, #59 * potential fix for stuck progress/canceled printing status, #52
This commit is contained in:
@@ -22,7 +22,7 @@ class PrintingState(APrinterState):
|
||||
|
||||
def __init__(self, printer: BambuVirtualPrinter) -> None:
|
||||
super().__init__(printer)
|
||||
self._current_print_job = None
|
||||
self._printer.current_print_job = None
|
||||
self._is_printing = False
|
||||
self._sd_printing_thread = None
|
||||
|
||||
@@ -40,12 +40,15 @@ class PrintingState(APrinterState):
|
||||
self._printer.current_print_job = None
|
||||
|
||||
def _start_worker_thread(self):
|
||||
self._is_printing = True
|
||||
if self._sd_printing_thread is None:
|
||||
self._is_printing = True
|
||||
self._sd_printing_thread = threading.Thread(target=self._printing_worker)
|
||||
self._sd_printing_thread.start()
|
||||
else:
|
||||
self._sd_printing_thread.join()
|
||||
|
||||
def _printing_worker(self):
|
||||
self._log.debug(f"_printing_worker before while loop: {self._printer.current_print_job}")
|
||||
while (
|
||||
self._is_printing
|
||||
and self._printer.current_print_job is not None
|
||||
@@ -55,6 +58,7 @@ class PrintingState(APrinterState):
|
||||
self._printer.report_print_job_status()
|
||||
time.sleep(3)
|
||||
|
||||
self._log.debug(f"_printing_worker after while loop: {self._printer.current_print_job}")
|
||||
self.update_print_job_info()
|
||||
if (
|
||||
self._printer.current_print_job is not None
|
||||
@@ -64,13 +68,15 @@ class PrintingState(APrinterState):
|
||||
|
||||
def update_print_job_info(self):
|
||||
print_job_info = self._printer.bambu_client.get_device().print_job
|
||||
task_name: str = print_job_info.subtask_name
|
||||
project_file_info = self._printer.project_files.get_file_by_stem(
|
||||
task_name, [".gcode", ".3mf"]
|
||||
)
|
||||
subtask_name: str = print_job_info.subtask_name
|
||||
gcode_file: str = print_job_info.gcode_file
|
||||
|
||||
self._log.info(f"update_print_job_info: {print_job_info}")
|
||||
|
||||
project_file_info = self._printer.project_files.get_file_by_name(subtask_name) or self._printer.project_files.get_file_by_name(gcode_file)
|
||||
if project_file_info is None:
|
||||
self._log.debug(f"No 3mf file found for {print_job_info}")
|
||||
self._current_print_job = None
|
||||
self._printer.current_print_job = None
|
||||
self._printer.change_state(self._printer._state_idle)
|
||||
return
|
||||
|
||||
|
Reference in New Issue
Block a user