mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 02:07:51 -06:00
Fixes for print job upload
This commit is contained in:
parent
8087fa421d
commit
9e4c71cce3
2 changed files with 12 additions and 5 deletions
|
@ -90,9 +90,11 @@ class MeshFormatHandler:
|
||||||
|
|
||||||
machine_file_formats = global_stack.getMetaDataEntry("file_formats").split(";")
|
machine_file_formats = global_stack.getMetaDataEntry("file_formats").split(";")
|
||||||
machine_file_formats = [file_type.strip() for file_type in machine_file_formats]
|
machine_file_formats = [file_type.strip() for file_type in machine_file_formats]
|
||||||
# Exception for UM3 firmware version >=4.4: UFP is now supported and should be the preferred file format.
|
|
||||||
if "application/x-ufp" not in machine_file_formats and Version(firmware_version) >= Version("4.4"):
|
# TODO: re-enable UFP after Cura master branch works again
|
||||||
machine_file_formats = ["application/x-ufp"] + machine_file_formats
|
# # Exception for UM3 firmware version >=4.4: UFP is now supported and should be the preferred file format.
|
||||||
|
# if "application/x-ufp" not in machine_file_formats and Version(firmware_version) >= Version("4.4"):
|
||||||
|
# machine_file_formats = ["application/x-ufp"] + machine_file_formats
|
||||||
|
|
||||||
# Take the intersection between file_formats and machine_file_formats.
|
# Take the intersection between file_formats and machine_file_formats.
|
||||||
format_by_mimetype = {f["mime_type"]: f for f in file_formats}
|
format_by_mimetype = {f["mime_type"]: f for f in file_formats}
|
||||||
|
|
|
@ -4,6 +4,7 @@ from typing import Optional, Dict, List, Any
|
||||||
|
|
||||||
from PyQt5.QtGui import QDesktopServices
|
from PyQt5.QtGui import QDesktopServices
|
||||||
from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty
|
from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty
|
||||||
|
from PyQt5.QtNetwork import QNetworkReply
|
||||||
|
|
||||||
from UM.FileHandler.FileHandler import FileHandler
|
from UM.FileHandler.FileHandler import FileHandler
|
||||||
from UM.FileHandler.WriteFileJob import WriteFileJob
|
from UM.FileHandler.WriteFileJob import WriteFileJob
|
||||||
|
@ -167,11 +168,15 @@ class NetworkOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
||||||
# It can now be sent over the network.
|
# It can now be sent over the network.
|
||||||
def _onPrintJobCreated(self, job: WriteFileJob) -> None:
|
def _onPrintJobCreated(self, job: WriteFileJob) -> None:
|
||||||
self._progress.show()
|
self._progress.show()
|
||||||
|
# TODO: extract multi-part stuff
|
||||||
parts = []
|
parts = []
|
||||||
parts.append(self._createFormPart("name=owner", bytes(self._getUserName(), "utf-8"), "text/plain"))
|
parts.append(self._createFormPart("name=owner", bytes(self._getUserName(), "utf-8"), "text/plain"))
|
||||||
output = job.getStream().getvalue()
|
output = job.getStream().getvalue()
|
||||||
|
if isinstance(output, str):
|
||||||
|
# Ensure that our output is bytes
|
||||||
|
output = output.encode("utf-8")
|
||||||
parts.append(self._createFormPart("name=\"file\"; filename=\"%s\"" % job.getFileName(), output))
|
parts.append(self._createFormPart("name=\"file\"; filename=\"%s\"" % job.getFileName(), output))
|
||||||
self.postFormWithParts("print_jobs/", parts, on_finished=self._onPrintUploadCompleted,
|
self.postFormWithParts("/cluster-api/v1/print_jobs/", parts, on_finished=self._onPrintUploadCompleted,
|
||||||
on_progress=self._onPrintJobUploadProgress)
|
on_progress=self._onPrintJobUploadProgress)
|
||||||
|
|
||||||
## Handler for print job upload progress.
|
## Handler for print job upload progress.
|
||||||
|
@ -181,7 +186,7 @@ class NetworkOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
||||||
self.writeProgress.emit()
|
self.writeProgress.emit()
|
||||||
|
|
||||||
## Handler for when the print job was fully uploaded to the cluster.
|
## Handler for when the print job was fully uploaded to the cluster.
|
||||||
def _onPrintUploadCompleted(self) -> None:
|
def _onPrintUploadCompleted(self, reply: QNetworkReply) -> None:
|
||||||
self._progress.hide()
|
self._progress.hide()
|
||||||
Message(
|
Message(
|
||||||
text=I18N_CATALOG.i18nc("@info:status", "Print job was successfully sent to the printer."),
|
text=I18N_CATALOG.i18nc("@info:status", "Print job was successfully sent to the printer."),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue