From ac0192f01f72c859effe05ae7ce9dc7a536d9220 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 9 Jul 2018 11:29:25 +0200 Subject: [PATCH] Improve fixes --- plugins/CuraEngineBackend/CuraEngineBackend.py | 10 +++++++--- plugins/SliceInfoPlugin/SliceInfo.py | 10 +++++++--- plugins/Toolbox/src/Toolbox.py | 2 +- plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py | 7 +++++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index 26a2399567..60436a3ef2 100755 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/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 diff --git a/plugins/SliceInfoPlugin/SliceInfo.py b/plugins/SliceInfoPlugin/SliceInfo.py index aad1b5005d..2e9e557c4a 100755 --- a/plugins/SliceInfoPlugin/SliceInfo.py +++ b/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() diff --git a/plugins/Toolbox/src/Toolbox.py b/plugins/Toolbox/src/Toolbox.py index 762e7027fb..7c2605e5e0 100644 --- a/plugins/Toolbox/src/Toolbox.py +++ b/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: diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index c6e384a987..b58601db46 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/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"):