Просмотр исходного кода

Fix type errors

Nothing really changed but it should be more type-safe now for the messages it creates and the build plate temperature.
Ghostkeeper 6 лет назад
Родитель
Сommit
25b18dee7a

+ 4 - 4
plugins/UM3NetworkPrinting/src/ClusterUM3OutputDevice.py

@@ -1,4 +1,4 @@
-# Copyright (c) 2018 Ultimaker B.V.
+# Copyright (c) 2019 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 from typing import Any, cast, Tuple, Union, Optional, Dict, List
@@ -195,7 +195,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
         self._progress_message = Message(i18n_catalog.i18nc("@info:status", "Sending data to printer"), lifetime = 0,
                                          dismissable = False, progress = -1,
                                          title = i18n_catalog.i18nc("@info:title", "Sending Data"))
-        self._progress_message.addAction("Abort", i18n_catalog.i18nc("@action:button", "Cancel"), icon = None,
+        self._progress_message.addAction("Abort", i18n_catalog.i18nc("@action:button", "Cancel"), icon = "",
                                          description = "")
         self._progress_message.actionTriggered.connect(self._progressMessageActionTriggered)
         self._progress_message.show()
@@ -256,7 +256,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
             # Treat upload progress as response. Uploading can take more than 10 seconds, so if we don't, we can get
             # timeout responses if this happens.
             self._last_response_time = time()
-            if self._progress_message is not None and new_progress > self._progress_message.getProgress():
+            if self._progress_message is not None and new_progress != self._progress_message.getProgress():
                 self._progress_message.show()  # Ensure that the message is visible.
                 self._progress_message.setProgress(bytes_sent / bytes_total * 100)
 
@@ -268,7 +268,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
                     i18n_catalog.i18nc("@info:status", "Print job was successfully sent to the printer."),
                     lifetime=5, dismissable=True,
                     title=i18n_catalog.i18nc("@info:title", "Data Sent"))
-                self._success_message.addAction("View", i18n_catalog.i18nc("@action:button", "View in Monitor"), icon=None,
+                self._success_message.addAction("View", i18n_catalog.i18nc("@action:button", "View in Monitor"), icon = "",
                                                 description="")
                 self._success_message.actionTriggered.connect(self._successMessageActionTriggered)
                 self._success_message.show()

+ 3 - 3
plugins/UM3NetworkPrinting/src/LegacyUM3PrinterOutputController.py

@@ -1,4 +1,4 @@
-# Copyright (c) 2017 Ultimaker B.V.
+# Copyright (c) 2019 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 from cura.PrinterOutput.PrinterOutputController import PrinterOutputController
@@ -33,9 +33,9 @@ class LegacyUM3PrinterOutputController(PrinterOutputController):
         data = "{\"target\": \"%s\"}" % state
         self._output_device.put("print_job/state", data, on_finished=None)
 
-    def setTargetBedTemperature(self, printer: "PrinterOutputModel", temperature: int):
+    def setTargetBedTemperature(self, printer: "PrinterOutputModel", temperature: float):
         data = str(temperature)
-        self._output_device.put("printer/bed/temperature/target", data, on_finished=self._onPutBedTemperatureCompleted)
+        self._output_device.put("printer/bed/temperature/target", data, on_finished = self._onPutBedTemperatureCompleted)
 
     def _onPutBedTemperatureCompleted(self, reply):
         if Version(self._preheat_printer.firmwareVersion) < Version("3.5.92"):

+ 6 - 6
plugins/UM3NetworkPrinting/src/SendMaterialJob.py

@@ -1,14 +1,14 @@
-# Copyright (c) 2018 Ultimaker B.V.
+# Copyright (c) 2019 Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
+
 import json
 import os
 from typing import Dict, TYPE_CHECKING, Set, Optional
-
 from PyQt5.QtNetwork import QNetworkReply, QNetworkRequest
 
-from UM.Application import Application
 from UM.Job import Job
 from UM.Logger import Logger
+from cura.CuraApplication import CuraApplication
 
 # Absolute imports don't work in plugins
 from .Models import ClusterMaterial, LocalMaterial
@@ -86,8 +86,8 @@ class SendMaterialJob(Job):
     #
     #   \param materials_to_send A set with id's of materials that must be sent.
     def _sendMaterials(self, materials_to_send: Set[str]) -> None:
-        container_registry = Application.getInstance().getContainerRegistry()
-        material_manager = Application.getInstance().getMaterialManager()
+        container_registry = CuraApplication.getInstance().getContainerRegistry()
+        material_manager = CuraApplication.getInstance().getMaterialManager()
         material_group_dict = material_manager.getAllMaterialGroups()
 
         for root_material_id in material_group_dict:
@@ -166,7 +166,7 @@ class SendMaterialJob(Job):
     #   \return a dictionary of LocalMaterial objects by GUID
     def _getLocalMaterials(self) -> Dict[str, LocalMaterial]:
         result = {}  # type: Dict[str, LocalMaterial]
-        material_manager = Application.getInstance().getMaterialManager()
+        material_manager = CuraApplication.getInstance().getMaterialManager()
 
         material_group_dict = material_manager.getAllMaterialGroups()