mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-12 09:17:50 -06:00
Merge branch 'cloud-output-device' of github.com:Ultimaker/Cura into cloud-output-device
This commit is contained in:
commit
8a72ba3cfa
28 changed files with 816 additions and 59 deletions
|
@ -47,7 +47,6 @@ class CloudOutputDeviceManager(NetworkClient):
|
|||
self._update_clusters_thread = Thread(target=self._updateClusters, daemon=True)
|
||||
self._update_clusters_thread.start()
|
||||
|
||||
|
||||
## Override _createEmptyRequest to add the needed authentication header for talking to the Ultimaker Cloud API.
|
||||
def _createEmptyRequest(self, path: str, content_type: Optional[str] = "application/json") -> QNetworkRequest:
|
||||
request = super()._createEmptyRequest(self.API_ROOT_PATH + path, content_type = content_type)
|
||||
|
@ -97,7 +96,7 @@ class CloudOutputDeviceManager(NetworkClient):
|
|||
@staticmethod
|
||||
def _parseStatusResponse(reply: QNetworkReply) -> Dict[str, CloudCluster]:
|
||||
try:
|
||||
return {c["guid"]: CloudCluster(**c) for c in json.loads(reply.readAll().data().decode("utf-8"))}
|
||||
return {c["cluster_id"]: CloudCluster(**c) for c in json.loads(reply.readAll().data().decode("utf-8"))}
|
||||
except UnicodeDecodeError:
|
||||
Logger.log("w", "Unable to read server response")
|
||||
except json.decoder.JSONDecodeError:
|
||||
|
|
|
@ -14,7 +14,7 @@ class BaseModel:
|
|||
|
||||
## Class representing a material that was fetched from the cluster API.
|
||||
class ClusterMaterial(BaseModel):
|
||||
def __init__(self, guid = str, version = str, **kwargs) -> None:
|
||||
def __init__(self, guid: str, version: int, **kwargs) -> None:
|
||||
self.guid = guid # type: str
|
||||
self.version = version # type: int
|
||||
super().__init__(**kwargs)
|
||||
|
@ -28,7 +28,7 @@ class ClusterMaterial(BaseModel):
|
|||
|
||||
## Class representing a local material that was fetched from the container registry.
|
||||
class LocalMaterial(BaseModel):
|
||||
def __init__(self, GUID = str, id = str, version = str, **kwargs) -> None:
|
||||
def __init__(self, GUID: str, id: str, version: int, **kwargs) -> None:
|
||||
self.GUID = GUID # type: str
|
||||
self.id = id # type: str
|
||||
self.version = version # type: int
|
||||
|
|
|
@ -160,7 +160,9 @@ class SendMaterialJob(Job):
|
|||
except json.JSONDecodeError:
|
||||
Logger.log("e", "Request material storage on printer: I didn't understand the printer's answer.")
|
||||
except ValueError:
|
||||
Logger.log("e", "Request material storage on printer: Printer's answer was missing a value.")
|
||||
Logger.log("e", "Request material storage on printer: Printer's answer had an incorrect value.")
|
||||
except TypeError:
|
||||
Logger.log("e", "Request material storage on printer: Printer's answer was missing a required value.")
|
||||
|
||||
## Retrieves a list of local materials
|
||||
#
|
||||
|
@ -189,5 +191,7 @@ class SendMaterialJob(Job):
|
|||
Logger.logException("w", "Local material {} has missing values.".format(material["id"]))
|
||||
except ValueError:
|
||||
Logger.logException("w", "Local material {} has invalid values.".format(material["id"]))
|
||||
except TypeError:
|
||||
Logger.logException("w", "Local material {} has invalid values.".format(material["id"]))
|
||||
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue