Verified Commit fb3d31d7 authored by Grégor JOUET's avatar Grégor JOUET 🔧
Browse files

Add normal print ending

parent b8d1844b
Loading
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ from myfab.model import (
    Queue,
    Printer,
    PrinterQueue,
    Event
)
from multiprocessing import Lock
import time
@@ -44,6 +45,13 @@ DEFAULT_PRINTER_STATE = {
    },
}

def add_request_event(req: PrintRequest, desc: str, op: User = None):
    log.info("Req %s: %s" % (req.id, desc))
    req.last_modification = datetime.datetime.now()
    req.save()
    Event.create(request=req, description=desc, operator=op)


# region QUEUE UTILS


@@ -517,6 +525,7 @@ class OctoPrinter(PrinterBase):
        if reason == RESET_CANCEL or reason == RESET_ERROR or reason == RESET_FAILURE:
            self.printer_obj.current_print.status = 11 # REQUEST_STATUS_PRINT_FAILED
        if reason == RESET_SUCCESS:
            add_request_event(self.printer_obj.current_print, "Normal Print Ending", None)
            self.printer_obj.current_print.status = 7 # REQUEST_STATUS_INSPECTING
        self.printer_obj.current_print.save()
        # TODO v3 : Printer statistics