mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-11 08:47:50 -06:00
Add specific message when sending a print to an inactive printer
CURA-12557
This commit is contained in:
parent
6ac622826e
commit
65b0e4f080
3 changed files with 50 additions and 8 deletions
|
@ -163,7 +163,7 @@ class CloudApiClient:
|
||||||
scope=self._scope,
|
scope=self._scope,
|
||||||
data=b"",
|
data=b"",
|
||||||
callback=self._parseCallback(on_finished, CloudPrintResponse),
|
callback=self._parseCallback(on_finished, CloudPrintResponse),
|
||||||
error_callback=on_error,
|
error_callback=self._parseError(on_error),
|
||||||
timeout=self.DEFAULT_REQUEST_TIMEOUT)
|
timeout=self.DEFAULT_REQUEST_TIMEOUT)
|
||||||
|
|
||||||
def doPrintJobAction(self, cluster_id: str, cluster_job_id: str, action: str,
|
def doPrintJobAction(self, cluster_id: str, cluster_job_id: str, action: str,
|
||||||
|
@ -256,7 +256,6 @@ class CloudApiClient:
|
||||||
"""Creates a callback function so that it includes the parsing of the response into the correct model.
|
"""Creates a callback function so that it includes the parsing of the response into the correct model.
|
||||||
|
|
||||||
The callback is added to the 'finished' signal of the reply.
|
The callback is added to the 'finished' signal of the reply.
|
||||||
:param reply: The reply that should be listened to.
|
|
||||||
:param on_finished: The callback in case the response is successful. Depending on the endpoint it will be either
|
:param on_finished: The callback in case the response is successful. Depending on the endpoint it will be either
|
||||||
a list or a single item.
|
a list or a single item.
|
||||||
:param model: The type of the model to convert the response to.
|
:param model: The type of the model to convert the response to.
|
||||||
|
@ -281,6 +280,25 @@ class CloudApiClient:
|
||||||
self._anti_gc_callbacks.append(parse)
|
self._anti_gc_callbacks.append(parse)
|
||||||
return parse
|
return parse
|
||||||
|
|
||||||
|
def _parseError(self,
|
||||||
|
on_error: Callable[[CloudError, "QNetworkReply.NetworkError", int], None]) -> Callable[[QNetworkReply, "QNetworkReply.NetworkError"], None]:
|
||||||
|
|
||||||
|
"""Creates a callback function so that it includes the parsing of an explicit error response into the correct model.
|
||||||
|
|
||||||
|
:param on_error: The callback in case the response gives an explicit error
|
||||||
|
"""
|
||||||
|
|
||||||
|
def parse(reply: QNetworkReply, error: "QNetworkReply.NetworkError") -> None:
|
||||||
|
|
||||||
|
self._anti_gc_callbacks.remove(parse)
|
||||||
|
|
||||||
|
http_code, response = self._parseReply(reply)
|
||||||
|
result = CloudError(**response["errors"][0])
|
||||||
|
on_error(result, error, http_code)
|
||||||
|
|
||||||
|
self._anti_gc_callbacks.append(parse)
|
||||||
|
return parse
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def getMachineIDMap(cls) -> Dict[str, str]:
|
def getMachineIDMap(cls) -> Dict[str, str]:
|
||||||
if cls._machine_id_to_name is None:
|
if cls._machine_id_to_name is None:
|
||||||
|
|
|
@ -27,9 +27,11 @@ from ..UltimakerNetworkedPrinterOutputDevice import UltimakerNetworkedPrinterOut
|
||||||
from ..Messages.PrintJobUploadBlockedMessage import PrintJobUploadBlockedMessage
|
from ..Messages.PrintJobUploadBlockedMessage import PrintJobUploadBlockedMessage
|
||||||
from ..Messages.PrintJobUploadErrorMessage import PrintJobUploadErrorMessage
|
from ..Messages.PrintJobUploadErrorMessage import PrintJobUploadErrorMessage
|
||||||
from ..Messages.PrintJobUploadQueueFullMessage import PrintJobUploadQueueFullMessage
|
from ..Messages.PrintJobUploadQueueFullMessage import PrintJobUploadQueueFullMessage
|
||||||
|
from ..Messages.PrintJobUploadPrinterInactiveMessage import PrintJobUploadPrinterInactiveMessage
|
||||||
from ..Messages.PrintJobUploadSuccessMessage import PrintJobUploadSuccessMessage
|
from ..Messages.PrintJobUploadSuccessMessage import PrintJobUploadSuccessMessage
|
||||||
from ..Models.Http.CloudClusterResponse import CloudClusterResponse
|
from ..Models.Http.CloudClusterResponse import CloudClusterResponse
|
||||||
from ..Models.Http.CloudClusterStatus import CloudClusterStatus
|
from ..Models.Http.CloudClusterStatus import CloudClusterStatus
|
||||||
|
from ..Models.Http.CloudError import CloudError
|
||||||
from ..Models.Http.CloudPrintJobUploadRequest import CloudPrintJobUploadRequest
|
from ..Models.Http.CloudPrintJobUploadRequest import CloudPrintJobUploadRequest
|
||||||
from ..Models.Http.CloudPrintResponse import CloudPrintResponse
|
from ..Models.Http.CloudPrintResponse import CloudPrintResponse
|
||||||
from ..Models.Http.CloudPrintJobResponse import CloudPrintJobResponse
|
from ..Models.Http.CloudPrintJobResponse import CloudPrintJobResponse
|
||||||
|
@ -291,19 +293,21 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
||||||
|
|
||||||
self.writeFinished.emit()
|
self.writeFinished.emit()
|
||||||
|
|
||||||
def _onPrintUploadSpecificError(self, reply: "QNetworkReply", _: "QNetworkReply.NetworkError"):
|
def _onPrintUploadSpecificError(self, error: CloudError, _: "QNetworkReply.NetworkError", http_error: int):
|
||||||
"""
|
"""
|
||||||
Displays a message when an error occurs specific to uploading print job (i.e. queue is full).
|
Displays a message when an error occurs specific to uploading print job (i.e. queue is full).
|
||||||
"""
|
"""
|
||||||
error_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
|
if http_error == 409:
|
||||||
if error_code == 409:
|
if error.code == "printerInactive":
|
||||||
|
PrintJobUploadPrinterInactiveMessage().show()
|
||||||
|
else:
|
||||||
PrintJobUploadQueueFullMessage().show()
|
PrintJobUploadQueueFullMessage().show()
|
||||||
else:
|
else:
|
||||||
PrintJobUploadErrorMessage(I18N_CATALOG.i18nc("@error:send",
|
PrintJobUploadErrorMessage(I18N_CATALOG.i18nc("@error:send",
|
||||||
"Unknown error code when uploading print job: {0}",
|
"Unknown error code when uploading print job: {0}",
|
||||||
error_code)).show()
|
http_error)).show()
|
||||||
|
|
||||||
Logger.log("w", "Upload of print job failed specifically with error code {}".format(error_code))
|
Logger.log("w", "Upload of print job failed specifically with error code {}".format(http_error))
|
||||||
|
|
||||||
self._progress.hide()
|
self._progress.hide()
|
||||||
self._pre_upload_print_job = None
|
self._pre_upload_print_job = None
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Copyright (c) 2020 Ultimaker B.V.
|
||||||
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
from UM import i18nCatalog
|
||||||
|
from UM.Message import Message
|
||||||
|
|
||||||
|
|
||||||
|
I18N_CATALOG = i18nCatalog("cura")
|
||||||
|
|
||||||
|
|
||||||
|
class PrintJobUploadPrinterInactiveMessage(Message):
|
||||||
|
"""Message shown when uploading a print job to a cluster and the printer is inactive."""
|
||||||
|
|
||||||
|
def __init__(self) -> None:
|
||||||
|
super().__init__(
|
||||||
|
text = I18N_CATALOG.i18nc("@info:status", "The printer is inactive and cannot accept a new print job."),
|
||||||
|
title = I18N_CATALOG.i18nc("@info:title", "Printer inactive"),
|
||||||
|
lifetime = 10,
|
||||||
|
message_type=Message.MessageType.ERROR
|
||||||
|
)
|
Loading…
Add table
Add a link
Reference in a new issue