Browse Source

Fix typing

Lipu Fei 5 years ago
parent
commit
4b8a216771

+ 2 - 2
cura/PrinterOutput/NetworkedPrinterOutputDevice.py

@@ -60,8 +60,8 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice):
         self._gcode = []                    # type: List[str]
         self._gcode = []                    # type: List[str]
         self._connection_state_before_timeout = None    # type: Optional[ConnectionState]
         self._connection_state_before_timeout = None    # type: Optional[ConnectionState]
 
 
-    def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False,
-                     file_handler: Optional[FileHandler] = None, **kwargs: str) -> None:
+    def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
+                     file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None:
         raise NotImplementedError("requestWrite needs to be implemented")
         raise NotImplementedError("requestWrite needs to be implemented")
 
 
     def setAuthenticationState(self, authentication_state: AuthState) -> None:
     def setAuthenticationState(self, authentication_state: AuthState) -> None:

+ 1 - 1
cura/PrinterOutput/PrinterOutputDevice.py

@@ -144,7 +144,7 @@ class PrinterOutputDevice(QObject, OutputDevice):
         return None
         return None
 
 
     def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
     def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
-                     file_handler: Optional["FileHandler"] = None, **kwargs: str) -> None:
+                     file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None:
         raise NotImplementedError("requestWrite needs to be implemented")
         raise NotImplementedError("requestWrite needs to be implemented")
 
 
     @pyqtProperty(QObject, notify = printersChanged)
     @pyqtProperty(QObject, notify = printersChanged)

+ 2 - 2
plugins/UM3NetworkPrinting/src/Cloud/CloudOutputDevice.py

@@ -171,8 +171,8 @@ class CloudOutputDevice(NetworkedPrinterOutputDevice):
         self.setConnectionText(I18N_CATALOG.i18nc("@info:status", "Connected via Cloud"))
         self.setConnectionText(I18N_CATALOG.i18nc("@info:status", "Connected via Cloud"))
 
 
     ##  Called when Cura requests an output device to receive a (G-code) file.
     ##  Called when Cura requests an output device to receive a (G-code) file.
-    def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False,
-                     file_handler: Optional[FileHandler] = None, **kwargs: str) -> None:
+    def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
+                     file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None:
 
 
         # Show an error message if we're already sending a job.
         # Show an error message if we're already sending a job.
         if self._progress.visible:
         if self._progress.visible:

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

@@ -106,8 +106,8 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
 
 
         self._active_camera_url = QUrl()  # type: QUrl
         self._active_camera_url = QUrl()  # type: QUrl
 
 
-    def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False,
-                     file_handler: Optional[FileHandler] = None, **kwargs: str) -> None:
+    def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
+                     file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None:
         self.writeStarted.emit(self)
         self.writeStarted.emit(self)
 
 
         self.sendMaterialProfiles()
         self.sendMaterialProfiles()

+ 2 - 1
plugins/UM3NetworkPrinting/src/LegacyUM3OutputDevice.py

@@ -178,7 +178,8 @@ class LegacyUM3OutputDevice(NetworkedPrinterOutputDevice):
                 # NotImplementedError. We can simply ignore these.
                 # NotImplementedError. We can simply ignore these.
                 pass
                 pass
 
 
-    def requestWrite(self, nodes: List[SceneNode], file_name: Optional[str] = None, limit_mimetypes: bool = False, file_handler: Optional[FileHandler] = None, **kwargs: str) -> None:
+    def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
+                     file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None:
         if not self.activePrinter:
         if not self.activePrinter:
             # No active printer. Unable to write
             # No active printer. Unable to write
             return
             return

+ 9 - 3
plugins/USBPrinting/USBPrinterOutputDevice.py

@@ -24,11 +24,15 @@ from queue import Queue
 from serial import Serial, SerialException, SerialTimeoutException
 from serial import Serial, SerialException, SerialTimeoutException
 from threading import Thread, Event
 from threading import Thread, Event
 from time import time
 from time import time
-from typing import Union, Optional, List, cast
+from typing import Union, Optional, List, cast, TYPE_CHECKING
 
 
 import re
 import re
 import functools  # Used for reduce
 import functools  # Used for reduce
 
 
+if TYPE_CHECKING:
+    from UM.FileHandler.FileHandler import FileHandler
+    from UM.Scene.SceneNode import SceneNode
+
 catalog = i18nCatalog("cura")
 catalog = i18nCatalog("cura")
 
 
 
 
@@ -117,14 +121,16 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
     #   \param filter_by_machine Whether to filter MIME types by machine. This
     #   \param filter_by_machine Whether to filter MIME types by machine. This
     #   is ignored.
     #   is ignored.
     #   \param kwargs Keyword arguments.
     #   \param kwargs Keyword arguments.
-    def requestWrite(self, nodes, file_name: str = None, filter_by_machine = False, file_handler = None, **kwargs):
+    def requestWrite(self, nodes: List["SceneNode"], file_name: Optional[str] = None, limit_mimetypes: bool = False,
+                     file_handler: Optional["FileHandler"] = None, filter_by_machine: bool = False, **kwargs) -> None:
         if self._is_printing:
         if self._is_printing:
             message = Message(text = catalog.i18nc("@message", "A print is still in progress. Cura cannot start another print via USB until the previous print has completed."), title = catalog.i18nc("@message", "Print in Progress"))
             message = Message(text = catalog.i18nc("@message", "A print is still in progress. Cura cannot start another print via USB until the previous print has completed."), title = catalog.i18nc("@message", "Print in Progress"))
             message.show()
             message.show()
             return  # Already printing
             return  # Already printing
         self.writeStarted.emit(self)
         self.writeStarted.emit(self)
         # cancel any ongoing preheat timer before starting a print
         # cancel any ongoing preheat timer before starting a print
-        self._printers[0].getController().stopPreheatTimers()
+        controller = cast(GenericOutputController, self._printers[0].getController())
+        controller.stopPreheatTimers()
 
 
         CuraApplication.getInstance().getController().setActiveStage("MonitorStage")
         CuraApplication.getInstance().getController().setActiveStage("MonitorStage")