mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 01:37:51 -06:00
Merge branch 'STAR-322_cloud-connection' of github.com:Ultimaker/Cura into STAR-322_cloud-connection
This commit is contained in:
commit
99bdb9c93f
8 changed files with 69 additions and 68 deletions
|
@ -6,7 +6,7 @@ import os
|
|||
from json import JSONDecodeError
|
||||
from typing import List, Optional, Dict, cast, Union, Tuple
|
||||
|
||||
from PyQt5.QtCore import QObject, pyqtSignal, QUrl, pyqtProperty
|
||||
from PyQt5.QtCore import QObject, pyqtSignal, QUrl, pyqtProperty, pyqtSlot
|
||||
from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest
|
||||
|
||||
from UM import i18nCatalog
|
||||
|
@ -209,6 +209,16 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
|||
return [print_job for print_job in self._print_jobs
|
||||
if print_job.state == "queued" or print_job.state == "error"]
|
||||
|
||||
## Get remote print jobs that are assigned to a printer.
|
||||
@pyqtProperty("QVariantList", notify = printJobsChanged)
|
||||
def activePrintJobs(self) -> List[UM3PrintJobOutputModel]:
|
||||
return [print_job for print_job in self._print_jobs if
|
||||
print_job.assignedPrinter is not None and print_job.state != "queued"]
|
||||
|
||||
@pyqtProperty(bool, notify = printJobsChanged)
|
||||
def receivedPrintJobs(self) -> bool:
|
||||
return not self._sending_job
|
||||
|
||||
## Called when the connection to the cluster changes.
|
||||
def connect(self) -> None:
|
||||
super().connect()
|
||||
|
@ -375,7 +385,7 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
|||
# TODO: Multipart upload
|
||||
job_response = JobUploadResponse(**response.get("data"))
|
||||
Logger.log("i", "Print job created successfully: %s", job_response.__dict__)
|
||||
self.put(job_response.upload_url, data = mesh,
|
||||
self.put(job_response.upload_url, data = mesh, content_type = job_response.content_type,
|
||||
on_finished = lambda r: self._onPrintJobUploaded(job_response.job_id, r),
|
||||
on_progress = self._onUploadPrintJobProgress)
|
||||
|
||||
|
@ -448,3 +458,22 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
|
|||
message.show()
|
||||
self._sending_job = False # the upload has finished so we're not sending a job anymore
|
||||
self.writeFinished.emit()
|
||||
|
||||
## TODO: The following methods are required by the monitor page QML, but are not actually available using cloud.
|
||||
# TODO: We fake the methods here to not break the monitor page.
|
||||
|
||||
@pyqtProperty(QObject, notify = printersChanged)
|
||||
def activePrinter(self) -> Optional[PrinterOutputModel]:
|
||||
return self._printers[0] or None
|
||||
|
||||
@pyqtSlot(QObject)
|
||||
def setActivePrinter(self, printer: Optional[PrinterOutputModel]) -> None:
|
||||
pass
|
||||
|
||||
@pyqtProperty(QUrl, notify = printersChanged)
|
||||
def activeCameraUrl(self) -> "QUrl":
|
||||
return QUrl()
|
||||
|
||||
@pyqtSlot(QUrl)
|
||||
def setActiveCameraUrl(self, camera_url: "QUrl") -> None:
|
||||
pass
|
||||
|
|
|
@ -131,6 +131,7 @@ class CloudOutputDeviceManager(NetworkClient):
|
|||
device = CloudOutputDevice(cluster.cluster_id)
|
||||
self._output_device_manager.addOutputDevice(device)
|
||||
self._remote_clusters[cluster.cluster_id] = device
|
||||
device.connect() # TODO: remove this
|
||||
self._connectToActiveMachine()
|
||||
|
||||
## Remove a CloudOutputDevice
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue