Fix local pause, resume and abort

This commit is contained in:
ChrisTerBeke 2019-07-29 17:31:05 +02:00
parent 1aa70748af
commit 93146610f7
2 changed files with 11 additions and 11 deletions

View file

@ -72,15 +72,15 @@ class ClusterApiClient:
url = f"{self.CLUSTER_API_PREFIX}/print_jobs/{print_job_uuid}" url = f"{self.CLUSTER_API_PREFIX}/print_jobs/{print_job_uuid}"
self._manager.deleteResource(self._createEmptyRequest(url)) self._manager.deleteResource(self._createEmptyRequest(url))
## Send a print job action to the cluster. ## Set the state of a print job.
# \param print_job_uuid: The UUID of the print job to perform the action on. def setPrintJobState(self, print_job_uuid: str, state: str) -> None:
# \param action: The action to perform. url = f"{self.CLUSTER_API_PREFIX}/print_jobs/{print_job_uuid}/action"
# \param data: The optional data to send along, used for 'move' and 'duplicate'. # We rewrite 'resume' to 'print' here because we are using the old print job action endpoints.
def doPrintJobAction(self, print_job_uuid: str, action: str, data: Optional[Dict[str, Union[str, int]]] = None action = "print" if state == "resume" else state
) -> None: self._manager.put(self._createEmptyRequest(url), json.dumps({"action": action}).encode())
url = f"{self.CLUSTER_API_PREFIX}/print_jobs/{print_job_uuid}/action/{action}/"
body = json.dumps(data).encode() if data else b"" def forcePrintJob(self, print_job_uuid: str) -> None:
self._manager.put(self._createEmptyRequest(url), body) pass # TODO
## We override _createEmptyRequest in order to add the user credentials. ## We override _createEmptyRequest in order to add the user credentials.
# \param url: The URL to request # \param url: The URL to request

View file

@ -96,13 +96,13 @@ class NetworkOutputDevice(UltimakerNetworkedPrinterOutputDevice):
@pyqtSlot(str, name="forceSendJob") @pyqtSlot(str, name="forceSendJob")
def forceSendJob(self, print_job_uuid: str) -> None: def forceSendJob(self, print_job_uuid: str) -> None:
self._cluster_api.doPrintJobAction(print_job_uuid, "force") self._cluster_api.forcePrintJob(print_job_uuid)
## Set the remote print job state. ## Set the remote print job state.
# \param print_job_uuid: The UUID of the print job to set the state for. # \param print_job_uuid: The UUID of the print job to set the state for.
# \param action: The action to undertake ('pause', 'resume', 'abort'). # \param action: The action to undertake ('pause', 'resume', 'abort').
def setJobState(self, print_job_uuid: str, action: str) -> None: def setJobState(self, print_job_uuid: str, action: str) -> None:
self._cluster_api.doPrintJobAction(print_job_uuid, action) self._cluster_api.setPrintJobState(print_job_uuid, action)
## Handle network errors. ## Handle network errors.
@staticmethod @staticmethod