|
@@ -7,7 +7,6 @@ from typing import Dict, List, Optional, Set, cast
|
|
|
|
|
|
from PyQt5.QtCore import QObject, QUrl, pyqtProperty, pyqtSignal, pyqtSlot
|
|
|
|
|
|
-from UM import i18nCatalog
|
|
|
from UM.Backend.Backend import BackendState
|
|
|
from UM.FileHandler.FileHandler import FileHandler
|
|
|
from UM.Logger import Logger
|
|
@@ -18,7 +17,8 @@ from cura.CuraApplication import CuraApplication
|
|
|
from cura.PrinterOutput.NetworkedPrinterOutputDevice import AuthState, NetworkedPrinterOutputDevice
|
|
|
from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel
|
|
|
from cura.PrinterOutputDevice import ConnectionType
|
|
|
-from plugins.UM3NetworkPrinting.src.Cloud.CloudOutputController import CloudOutputController
|
|
|
+
|
|
|
+from .CloudOutputController import CloudOutputController
|
|
|
from ..MeshFormatHandler import MeshFormatHandler
|
|
|
from ..UM3PrintJobOutputModel import UM3PrintJobOutputModel
|
|
|
from .CloudProgressMessage import CloudProgressMessage
|
|
@@ -30,37 +30,10 @@ from .Models.CloudPrintResponse import CloudPrintResponse
|
|
|
from .Models.CloudPrintJobResponse import CloudPrintJobResponse
|
|
|
from .Models.CloudClusterPrinterStatus import CloudClusterPrinterStatus
|
|
|
from .Models.CloudClusterPrintJobStatus import CloudClusterPrintJobStatus
|
|
|
+from .Translations import Translations
|
|
|
from .Utils import findChanges, formatDateCompleted, formatTimeCompleted
|
|
|
|
|
|
|
|
|
-## Class that contains all the translations for this module.
|
|
|
-class T:
|
|
|
- # The translation catalog for this device.
|
|
|
-
|
|
|
- _I18N_CATALOG = i18nCatalog("cura")
|
|
|
-
|
|
|
- PRINT_VIA_CLOUD_BUTTON = _I18N_CATALOG.i18nc("@action:button", "Print via Cloud")
|
|
|
- PRINT_VIA_CLOUD_TOOLTIP = _I18N_CATALOG.i18nc("@properties:tooltip", "Print via Cloud")
|
|
|
-
|
|
|
- CONNECTED_VIA_CLOUD = _I18N_CATALOG.i18nc("@info:status", "Connected via Cloud")
|
|
|
- BLOCKED_UPLOADING = _I18N_CATALOG.i18nc("@info:status", "Sending new jobs (temporarily) blocked, still sending "
|
|
|
- "the previous print job.")
|
|
|
-
|
|
|
- COULD_NOT_EXPORT = _I18N_CATALOG.i18nc("@info:status", "Could not export print job.")
|
|
|
-
|
|
|
- ERROR = _I18N_CATALOG.i18nc("@info:title", "Error")
|
|
|
- UPLOAD_ERROR = _I18N_CATALOG.i18nc("@info:text", "Could not upload the data to the printer.")
|
|
|
-
|
|
|
- UPLOAD_SUCCESS_TITLE = _I18N_CATALOG.i18nc("@info:title", "Data Sent")
|
|
|
- UPLOAD_SUCCESS_TEXT = _I18N_CATALOG.i18nc("@info:status", "Print job was successfully sent to the printer.")
|
|
|
-
|
|
|
- JOB_COMPLETED_TITLE = _I18N_CATALOG.i18nc("@info:status", "Print finished")
|
|
|
- JOB_COMPLETED_PRINTER = _I18N_CATALOG.i18nc("@info:status",
|
|
|
- "Printer '{printer_name}' has finished printing '{job_name}'.")
|
|
|
-
|
|
|
- JOB_COMPLETED_NO_PRINTER = _I18N_CATALOG.i18nc("@info:status", "The print job '{job_name}' was finished.")
|
|
|
-
|
|
|
-
|
|
|
## The cloud output device is a network output device that works remotely but has limited functionality.
|
|
|
# Currently it only supports viewing the printer and print job status and adding a new job to the queue.
|
|
|
# As such, those methods have been implemented here.
|
|
@@ -159,9 +132,9 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
|
|
def _setInterfaceElements(self) -> None:
|
|
|
self.setPriority(2) # make sure we end up below the local networking and above 'save to file'
|
|
|
self.setName(self._id)
|
|
|
- self.setShortDescription(T.PRINT_VIA_CLOUD_BUTTON)
|
|
|
- self.setDescription(T.PRINT_VIA_CLOUD_TOOLTIP)
|
|
|
- self.setConnectionText(T.CONNECTED_VIA_CLOUD)
|
|
|
+ self.setShortDescription(Translations.PRINT_VIA_CLOUD_BUTTON)
|
|
|
+ self.setDescription(Translations.PRINT_VIA_CLOUD_TOOLTIP)
|
|
|
+ self.setConnectionText(Translations.CONNECTED_VIA_CLOUD)
|
|
|
|
|
|
## Called when Cura requests an output device to receive a (G-code) file.
|
|
|
def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False,
|
|
@@ -169,7 +142,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
|
|
|
|
|
# Show an error message if we're already sending a job.
|
|
|
if self._progress.visible:
|
|
|
- message = Message(text = T.BLOCKED_UPLOADING, title = T.ERROR, lifetime = 10)
|
|
|
+ message = Message(text = Translations.BLOCKED_UPLOADING, title = Translations.ERROR, lifetime = 10)
|
|
|
message.show()
|
|
|
return
|
|
|
|
|
@@ -184,7 +157,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
|
|
mesh_format = MeshFormatHandler(file_handler, self.firmwareVersion)
|
|
|
if not mesh_format.is_valid:
|
|
|
Logger.log("e", "Missing file or mesh writer!")
|
|
|
- return self._onUploadError(T.COULD_NOT_EXPORT)
|
|
|
+ return self._onUploadError(Translations.COULD_NOT_EXPORT)
|
|
|
|
|
|
mesh = mesh_format.getBytes(nodes)
|
|
|
|
|
@@ -292,9 +265,11 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
|
|
if job.state == "wait_cleanup" and job.key not in self._finished_jobs and job.owner == user_name:
|
|
|
self._finished_jobs.add(job.key)
|
|
|
Message(
|
|
|
- title = T.JOB_COMPLETED_TITLE,
|
|
|
- text = (T.JOB_COMPLETED_PRINTER.format(printer_name=job.assignedPrinter.name, job_name=job.name)
|
|
|
- if job.assignedPrinter else T.JOB_COMPLETED_NO_PRINTER.format(job_name=job.name)),
|
|
|
+ title = Translations.JOB_COMPLETED_TITLE,
|
|
|
+ text = (Translations.JOB_COMPLETED_PRINTER.format(printer_name=job.assignedPrinter.name,
|
|
|
+ job_name=job.name)
|
|
|
+ if job.assignedPrinter else
|
|
|
+ Translations.JOB_COMPLETED_NO_PRINTER.format(job_name=job.name)),
|
|
|
).show()
|
|
|
|
|
|
# Ensure UI gets updated
|
|
@@ -330,7 +305,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
|
|
def _onUploadError(self, message = None) -> None:
|
|
|
self._progress.hide()
|
|
|
self._uploaded_print_job = None
|
|
|
- Message(text = message or T.UPLOAD_ERROR, title = T.ERROR, lifetime = 10).show()
|
|
|
+ Message(text = message or Translations.UPLOAD_ERROR, title = Translations.ERROR, lifetime = 10).show()
|
|
|
self.writeError.emit()
|
|
|
|
|
|
## Shows a message when the upload has succeeded
|
|
@@ -338,7 +313,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
|
|
def _onPrintRequested(self, response: CloudPrintResponse) -> None:
|
|
|
Logger.log("d", "The cluster will be printing this print job with the ID %s", response.cluster_job_id)
|
|
|
self._progress.hide()
|
|
|
- Message(text = T.UPLOAD_SUCCESS_TEXT, title = T.UPLOAD_SUCCESS_TITLE, lifetime = 5).show()
|
|
|
+ Message(text = Translations.UPLOAD_SUCCESS_TEXT, title = Translations.UPLOAD_SUCCESS_TITLE, lifetime = 5).show()
|
|
|
self.writeFinished.emit()
|
|
|
|
|
|
## Gets the remote printers.
|