mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-30 15:54:32 +08:00
Clean up codestyle violations
Boyscouting! CURA-8463
This commit is contained in:
parent
506f2b9820
commit
4ac8229c33
@ -41,7 +41,7 @@ I18N_CATALOG = i18nCatalog("cura")
|
|||||||
class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
||||||
"""The cloud output device is a network output device that works remotely but has limited functionality.
|
"""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.
|
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.
|
As such, those methods have been implemented here.
|
||||||
Note that this device represents a single remote cluster, not a list of multiple clusters.
|
Note that this device represents a single remote cluster, not a list of multiple clusters.
|
||||||
"""
|
"""
|
||||||
@ -58,7 +58,7 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||||||
PRINT_JOB_ACTIONS_MIN_VERSION = Version("5.2.12")
|
PRINT_JOB_ACTIONS_MIN_VERSION = Version("5.2.12")
|
||||||
|
|
||||||
# Notify can only use signals that are defined by the class that they are in, not inherited ones.
|
# Notify can only use signals that are defined by the class that they are in, not inherited ones.
|
||||||
# Therefore we create a private signal used to trigger the printersChanged signal.
|
# Therefore, we create a private signal used to trigger the printersChanged signal.
|
||||||
_cloudClusterPrintersChanged = pyqtSignal()
|
_cloudClusterPrintersChanged = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, api_client: CloudApiClient, cluster: CloudClusterResponse, parent: QObject = None) -> None:
|
def __init__(self, api_client: CloudApiClient, cluster: CloudClusterResponse, parent: QObject = None) -> None:
|
||||||
@ -202,7 +202,8 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||||||
# Note that self.writeFinished is called in _onPrintUploadCompleted as well.
|
# Note that self.writeFinished is called in _onPrintUploadCompleted as well.
|
||||||
if self._uploaded_print_job:
|
if self._uploaded_print_job:
|
||||||
Logger.log("i", "Current mesh is already attached to a print-job, immediately request reprint.")
|
Logger.log("i", "Current mesh is already attached to a print-job, immediately request reprint.")
|
||||||
self._api.requestPrint(self.key, self._uploaded_print_job.job_id, self._onPrintUploadCompleted, self._onPrintUploadSpecificError)
|
self._api.requestPrint(self.key, self._uploaded_print_job.job_id, self._onPrintUploadCompleted,
|
||||||
|
self._onPrintUploadSpecificError)
|
||||||
return
|
return
|
||||||
|
|
||||||
# Export the scene to the correct file type.
|
# Export the scene to the correct file type.
|
||||||
@ -244,12 +245,15 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||||||
|
|
||||||
self._progress.update(100)
|
self._progress.update(100)
|
||||||
print_job = cast(CloudPrintJobResponse, self._pre_upload_print_job)
|
print_job = cast(CloudPrintJobResponse, self._pre_upload_print_job)
|
||||||
if not print_job: # It's possible that another print job is requested in the meanwhile, which then fails to upload with an error, which sets self._pre_uploaded_print_job to `None`.
|
if not print_job:
|
||||||
|
# It's possible that another print job is requested in the meanwhile, which then fails to upload with an
|
||||||
|
# error, which sets self._pre_uploaded_print_job to `None`.
|
||||||
self._pre_upload_print_job = None
|
self._pre_upload_print_job = None
|
||||||
self._uploaded_print_job = None
|
self._uploaded_print_job = None
|
||||||
Logger.log("w", "Interference from another job uploaded at roughly the same time, not uploading print!")
|
Logger.log("w", "Interference from another job uploaded at roughly the same time, not uploading print!")
|
||||||
return # Prevent a crash.
|
return # Prevent a crash.
|
||||||
self._api.requestPrint(self.key, print_job.job_id, self._onPrintUploadCompleted, self._onPrintUploadSpecificError)
|
self._api.requestPrint(self.key, print_job.job_id, self._onPrintUploadCompleted,
|
||||||
|
self._onPrintUploadSpecificError)
|
||||||
|
|
||||||
def _onPrintUploadCompleted(self, response: CloudPrintResponse) -> None:
|
def _onPrintUploadCompleted(self, response: CloudPrintResponse) -> None:
|
||||||
"""Shows a message when the upload has succeeded
|
"""Shows a message when the upload has succeeded
|
||||||
@ -262,10 +266,13 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||||||
message.addAction("monitor print",
|
message.addAction("monitor print",
|
||||||
name=I18N_CATALOG.i18nc("@action:button", "Monitor print"),
|
name=I18N_CATALOG.i18nc("@action:button", "Monitor print"),
|
||||||
icon="",
|
icon="",
|
||||||
description=I18N_CATALOG.i18nc("@action:tooltip", "Track the print in Ultimaker Digital Factory"),
|
description=I18N_CATALOG.i18nc("@action:tooltip",
|
||||||
|
"Track the print in Ultimaker Digital Factory"),
|
||||||
button_align=message.ActionButtonAlignment.ALIGN_RIGHT)
|
button_align=message.ActionButtonAlignment.ALIGN_RIGHT)
|
||||||
df_url = f"https://digitalfactory.ultimaker.com/app/jobs/{self._cluster.cluster_id}?utm_source=cura&utm_medium=software&utm_campaign=message-printjob-sent"
|
df_url = f"https://digitalfactory.ultimaker.com/app/jobs/{self._cluster.cluster_id}" \
|
||||||
message.pyQtActionTriggered.connect(lambda message, action: (QDesktopServices.openUrl(QUrl(df_url)), message.hide()))
|
f"?utm_source=cura&utm_medium=software&utm_campaign=message-printjob-sent"
|
||||||
|
message.pyQtActionTriggered.connect(lambda message, action: (QDesktopServices.openUrl(QUrl(df_url)),
|
||||||
|
message.hide()))
|
||||||
|
|
||||||
message.show()
|
message.show()
|
||||||
self.writeFinished.emit()
|
self.writeFinished.emit()
|
||||||
@ -278,7 +285,9 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||||||
if error_code == 409:
|
if error_code == 409:
|
||||||
PrintJobUploadQueueFullMessage().show()
|
PrintJobUploadQueueFullMessage().show()
|
||||||
else:
|
else:
|
||||||
PrintJobUploadErrorMessage(I18N_CATALOG.i18nc("@error:send", "Unknown error code when uploading print job: {0}", error_code)).show()
|
PrintJobUploadErrorMessage(I18N_CATALOG.i18nc("@error:send",
|
||||||
|
"Unknown error code when uploading print job: {0}",
|
||||||
|
error_code)).show()
|
||||||
|
|
||||||
Logger.log("w", "Upload of print job failed specifically with error code {}".format(error_code))
|
Logger.log("w", "Upload of print job failed specifically with error code {}".format(error_code))
|
||||||
|
|
||||||
@ -336,11 +345,13 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||||||
|
|
||||||
@pyqtSlot(name="openPrintJobControlPanel")
|
@pyqtSlot(name="openPrintJobControlPanel")
|
||||||
def openPrintJobControlPanel(self) -> None:
|
def openPrintJobControlPanel(self) -> None:
|
||||||
QDesktopServices.openUrl(QUrl(self.clusterCloudUrl + "?utm_source=cura&utm_medium=software&utm_campaign=monitor-manage-browser"))
|
QDesktopServices.openUrl(QUrl(f"{self.clusterCloudUrl}?utm_source=cura&utm_medium=software&"
|
||||||
|
f"utm_campaign=monitor-manage-browser"))
|
||||||
|
|
||||||
@pyqtSlot(name="openPrinterControlPanel")
|
@pyqtSlot(name="openPrinterControlPanel")
|
||||||
def openPrinterControlPanel(self) -> None:
|
def openPrinterControlPanel(self) -> None:
|
||||||
QDesktopServices.openUrl(QUrl(self.clusterCloudUrl + "?utm_source=cura&utm_medium=software&utm_campaign=monitor-manage-printer"))
|
QDesktopServices.openUrl(QUrl(f"{self.clusterCloudUrl}?utm_source=cura&utm_medium=software"
|
||||||
|
f"&utm_campaign=monitor-manage-printer"))
|
||||||
|
|
||||||
permissionsChanged = pyqtSignal()
|
permissionsChanged = pyqtSignal()
|
||||||
|
|
||||||
@ -362,7 +373,7 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||||||
@pyqtProperty(bool, notify = permissionsChanged)
|
@pyqtProperty(bool, notify = permissionsChanged)
|
||||||
def canWriteOwnPrintJobs(self) -> bool:
|
def canWriteOwnPrintJobs(self) -> bool:
|
||||||
"""
|
"""
|
||||||
Whether this user can change things about print jobs made by themself.
|
Whether this user can change things about print jobs made by them.
|
||||||
"""
|
"""
|
||||||
return "digital-factory.print-job.write.own" in self._account.permissions
|
return "digital-factory.print-job.write.own" in self._account.permissions
|
||||||
|
|
||||||
@ -390,4 +401,4 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
|
|||||||
"""Gets the URL on which to monitor the cluster via the cloud."""
|
"""Gets the URL on which to monitor the cluster via the cloud."""
|
||||||
|
|
||||||
root_url_prefix = "-staging" if self._account.is_staging else ""
|
root_url_prefix = "-staging" if self._account.is_staging else ""
|
||||||
return "https://digitalfactory{}.ultimaker.com/app/jobs/{}".format(root_url_prefix, self.clusterData.cluster_id)
|
return f"https://digitalfactory{root_url_prefix}.ultimaker.com/app/jobs/{self.clusterData.cluster_id}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user