Browse Source

Improve fixes

Ian Paschal 6 years ago
parent
commit
ac0192f01f

+ 7 - 3
plugins/CuraEngineBackend/CuraEngineBackend.py

@@ -486,8 +486,8 @@ class CuraEngineBackend(QObject, Backend):
         else:
             # we got a single scenenode
             if not source.callDecoration("isGroup"):
-                meshData = source.getMeshData();
-                if meshData and meshData.getVertices() is None:
+                mesh_data = source.getMeshData()
+                if mesh_data and mesh_data.getVertices() is None:
                     return
 
             build_plate_changed.add(source_build_plate_number)
@@ -670,7 +670,11 @@ class CuraEngineBackend(QObject, Backend):
     ##  Creates a new socket connection.
     def _createSocket(self, protocol_file: str = None) -> None:
         if not protocol_file:
-            protocol_file = os.path.abspath(os.path.join(str(PluginRegistry.getInstance().getPluginPath(self.getPluginId())), "Cura.proto"))
+            plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId())
+            if not plugin_path:
+                Logger.log("e", "Could not get plugin path!", self.getPluginId())
+                return
+            protocol_file = os.path.abspath(os.path.join(plugin_path, "Cura.proto"))
         super()._createSocket(protocol_file)
         self._engine_is_fresh = True
 

+ 7 - 3
plugins/SliceInfoPlugin/SliceInfo.py

@@ -16,7 +16,7 @@ from UM.i18n import i18nCatalog
 from UM.Logger import Logger
 from UM.PluginRegistry import PluginRegistry
 from UM.Qt.Duration import DurationFormat
-from typing import cast
+from typing import cast, Optional
 from .SliceInfoJob import SliceInfoJob
 
 
@@ -79,9 +79,13 @@ class SliceInfo(QObject, Extension):
         return dialog
 
     @pyqtSlot(result = str)
-    def getExampleData(self) -> str:
+    def getExampleData(self) -> Optional[str]:
         if self._example_data_content is None:
-            file_path = os.path.join(cast(str, PluginRegistry.getInstance().getPluginPath(self.getPluginId())), "example_data.json")
+            plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId())
+            if not plugin_path:
+                Logger.log("e", "Could not get plugin path!", self.getPluginId())
+                return None
+            file_path = os.path.join(plugin_path, "example_data.json")
             if file_path:
                 with open(file_path, "r", encoding = "utf-8") as f:
                     self._example_data_content = f.read()

+ 1 - 1
plugins/Toolbox/src/Toolbox.py

@@ -234,7 +234,7 @@ class Toolbox(QObject, Extension):
         # Apply enabled/disabled state to installed plugins
         self.enabledChanged.emit()
 
-    def _createDialog(self, qml_name: str) -> QObject:
+    def _createDialog(self, qml_name: str) -> Optional[QObject]:
         Logger.log("d", "Toolbox: Creating dialog [%s].", qml_name)
         plugin_path = PluginRegistry.getInstance().getPluginPath(self.getPluginId())
         if not plugin_path:

+ 5 - 2
plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py

@@ -106,8 +106,11 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
 
         global_stack = CuraApplication.getInstance().getGlobalContainerStack()
         #Create a list from the supported file formats string.
-        if global_stack:
-            machine_file_formats = global_stack.getMetaDataEntry("file_formats").split(";")
+        if not global_stack:
+            Logger.log("e", "Missing global stack!")
+            return;
+
+        machine_file_formats = global_stack.getMetaDataEntry("file_formats").split(";")
         machine_file_formats = [file_type.strip() for file_type in machine_file_formats]
         #Exception for UM3 firmware version >=4.4: UFP is now supported and should be the preferred file format.
         if "application/x-ufp" not in machine_file_formats and self.printerType == "ultimaker3" and Version(self.firmwareVersion) >= Version("4.4"):