Add time & reason for failure to PrintFailed event
This commit is contained in:
1 parent
8939537fb5
commit
dae0264a58
3 files changed
+12
-2
No files matched your search
@@ -338,6 +338,8 @@ PrintFailed
|
||||
* ``name``: the file's name
|
||||
* ``path``: the file's path within its storage location
|
||||
* ``origin``: the origin storage location of the file, either ``local`` or ``sdcard``
|
||||
* ``time``: the elapsed time of the print when it failed, in seconds (float)
|
||||
* ``reason``: the reason the print failed, either ``cancelled`` or ``error``
|
||||
|
||||
.. deprecated:: 1.3.0
|
||||
|
||||
|
||||
@@ -973,6 +973,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
payload = self._payload_for_print_job_event()
|
||||
if payload:
|
||||
payload["time"] = self._comm.getPrintTime()
|
||||
payload["reason"] = "error"
|
||||
|
||||
def finalize():
|
||||
self._fileManager.log_print(payload["origin"],
|
||||
@@ -1103,8 +1104,14 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
self._stateMonitor.set_state(self._dict(text=self.get_state_string(), flags=self._getStateFlags()))
|
||||
|
||||
|
||||
def on_comm_print_job_failed(self):
|
||||
def on_comm_print_job_failed(self, reason=None):
|
||||
payload = self._payload_for_print_job_event()
|
||||
|
||||
if reason:
|
||||
payload["reason"] = reason
|
||||
else:
|
||||
payload["reason"] = "unknown"
|
||||
|
||||
if payload:
|
||||
eventManager().fire(Events.PRINT_FAILED, payload)
|
||||
|
||||
@@ -1122,6 +1129,7 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback):
|
||||
payload = self._payload_for_print_job_event(position=self._comm.cancel_position.as_dict() if self._comm and self._comm.cancel_position else None)
|
||||
if payload:
|
||||
payload["time"] = self._comm.getPrintTime()
|
||||
payload["reason"] = "cancelled"
|
||||
|
||||
eventManager().fire(Events.PRINT_CANCELLED, payload)
|
||||
if not suppress_script:
|
||||
|
||||
@@ -3600,7 +3600,7 @@ class MachineComPrintCallback(object):
|
||||
def on_comm_print_job_started(self, suppress_script=False):
|
||||
pass
|
||||
|
||||
def on_comm_print_job_failed(self):
|
||||
def on_comm_print_job_failed(self, reason=None):
|
||||
pass
|
||||
|
||||
def on_comm_print_job_done(self, suppress_script=False):
|
||||
|
||||
Reference in new issue
Block a user