From d3310be8462e7c2b2107324e565f3de5dacff0f2 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Fri, 12 Apr 2019 16:19:54 +0200 Subject: [PATCH 1/4] Deprecate some MachineManagaer functions. Note: You need the 'handle_log_once' branch in Uranium to prevent spamming the logs! part of CURA-6457 --- cura/Settings/MachineManager.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 7d0e7506b8..f4acbf2748 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -9,6 +9,7 @@ from typing import Any, List, Dict, TYPE_CHECKING, Optional, cast from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal, QTimer from UM.ConfigurationErrorMessage import ConfigurationErrorMessage +from UM.Decorators import deprecated from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Settings.InstanceContainer import InstanceContainer from UM.Settings.Interfaces import ContainerInterface @@ -498,30 +499,35 @@ class MachineManager(QObject): return bool(self._stacks_have_errors) @pyqtProperty(str, notify = globalContainerChanged) + @deprecated("use Cura.MachineManager.activeMachine.definition.getName instead", "4.1") def activeMachineDefinitionName(self) -> str: if self._global_container_stack: return self._global_container_stack.definition.getName() return "" @pyqtProperty(str, notify = globalContainerChanged) + @deprecated("use Cura.MachineManager.activeMachine.getName instead", "4.1") def activeMachineName(self) -> str: if self._global_container_stack: return self._global_container_stack.getMetaDataEntry("group_name", self._global_container_stack.getName()) return "" @pyqtProperty(str, notify = globalContainerChanged) + @deprecated("use Cura.MachineManager.activeMachine.getId instead", "4.1") def activeMachineId(self) -> str: if self._global_container_stack: return self._global_container_stack.getId() return "" @pyqtProperty(str, notify = globalContainerChanged) + @deprecated("use Cura.MachineManager.activeMachine.firmwareVersion instead", "4.1") def activeMachineFirmwareVersion(self) -> str: if not self._printer_output_devices: return "" return self._printer_output_devices[0].firmwareVersion @pyqtProperty(str, notify = globalContainerChanged) + @deprecated("use Cura.MachineManager.activeMachine.address instead", "4.1") def activeMachineAddress(self) -> str: if not self._printer_output_devices: return "" @@ -543,21 +549,25 @@ class MachineManager(QObject): return False @pyqtProperty("QVariantList", notify=globalContainerChanged) + @deprecated("use Cura.MachineManager.activeMachine.configuredConnectionTypes instead", "4.1") def activeMachineConfiguredConnectionTypes(self): if self._global_container_stack: return self._global_container_stack.configuredConnectionTypes return [] @pyqtProperty(bool, notify = printerConnectedStatusChanged) + @deprecated("use len(Cura.MachineManager.activeMachine.printers) instead", "4.1") def activeMachineIsGroup(self) -> bool: return bool(self._printer_output_devices) and len(self._printer_output_devices[0].printers) > 1 @pyqtProperty(bool, notify = printerConnectedStatusChanged) + @deprecated("use Cura.MachineManager.activeMachine.connectionType instead", "4.1") def activeMachineHasNetworkConnection(self) -> bool: # A network connection is only available if any output device is actually a network connected device. return any(d.connectionType == ConnectionType.NetworkConnection for d in self._printer_output_devices) @pyqtProperty(bool, notify = printerConnectedStatusChanged) + @deprecated("use Cura.MachineManager.activeMachine.connectionType instead", "4.1") def activeMachineHasCloudConnection(self) -> bool: # A cloud connection is only available if any output device actually is a cloud connected device. return any(d.connectionType == ConnectionType.CloudConnection for d in self._printer_output_devices) @@ -715,6 +725,7 @@ class MachineManager(QObject): extruder_stack.userChanges.setProperty(key, "value", new_value) @pyqtProperty(str, notify = activeVariantChanged) + @deprecated("use XXY instead", "4.1") def activeVariantName(self) -> str: if self._active_container_stack: variant = self._active_container_stack.variant @@ -733,6 +744,7 @@ class MachineManager(QObject): return "" @pyqtProperty(str, notify = activeVariantChanged) + @deprecated("use XXY instead", "4.1") def activeVariantBuildplateName(self) -> str: if self._global_container_stack: variant = self._global_container_stack.variant @@ -751,6 +763,7 @@ class MachineManager(QObject): ## Get the Definition ID to use to select quality profiles for the currently active machine # \returns DefinitionID (string) if found, empty string otherwise @pyqtProperty(str, notify = globalContainerChanged) + @deprecated("use XXY instead", "4.1") def activeQualityDefinitionId(self) -> str: if self._global_container_stack: return getMachineDefinitionIDForQualitySearch(self._global_container_stack.definition) From 5f7f7f944f34055d976183348caba85ca2e2a836 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 15 Apr 2019 09:39:05 +0200 Subject: [PATCH 2/4] Remove use XYZ instead --- cura/Settings/MachineManager.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index f4acbf2748..21826745e7 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -725,7 +725,7 @@ class MachineManager(QObject): extruder_stack.userChanges.setProperty(key, "value", new_value) @pyqtProperty(str, notify = activeVariantChanged) - @deprecated("use XXY instead", "4.1") + @deprecated("use Cura.activeStack.variant.name instead", "4.1") def activeVariantName(self) -> str: if self._active_container_stack: variant = self._active_container_stack.variant @@ -744,7 +744,7 @@ class MachineManager(QObject): return "" @pyqtProperty(str, notify = activeVariantChanged) - @deprecated("use XXY instead", "4.1") + @deprecated("use Cura.activeMachine.variant.name instead", "4.1") def activeVariantBuildplateName(self) -> str: if self._global_container_stack: variant = self._global_container_stack.variant @@ -763,7 +763,6 @@ class MachineManager(QObject): ## Get the Definition ID to use to select quality profiles for the currently active machine # \returns DefinitionID (string) if found, empty string otherwise @pyqtProperty(str, notify = globalContainerChanged) - @deprecated("use XXY instead", "4.1") def activeQualityDefinitionId(self) -> str: if self._global_container_stack: return getMachineDefinitionIDForQualitySearch(self._global_container_stack.definition) From ba37812793bb084ee70c9c36160effee97d3daf8 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 15 Apr 2019 09:47:09 +0200 Subject: [PATCH 3/4] Correct some deprecations and remove duplicated code --- cura/Settings/GlobalStack.py | 3 +++ cura/Settings/MachineManager.py | 19 ++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cura/Settings/GlobalStack.py b/cura/Settings/GlobalStack.py index df881b4714..df43b1c1f7 100755 --- a/cura/Settings/GlobalStack.py +++ b/cura/Settings/GlobalStack.py @@ -258,6 +258,9 @@ class GlobalStack(CuraContainerStack): def getHasVariants(self) -> bool: return parseBool(self.getMetaDataEntry("has_variants", False)) + def getHasVariantsBuildPlates(self) -> bool: + return parseBool(self._global_container_stack.getMetaDataEntry("has_variant_buildplates", False)) + def getHasMachineQuality(self) -> bool: return parseBool(self.getMetaDataEntry("has_machine_quality", False)) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 21826745e7..5832dd2fe6 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -499,35 +499,33 @@ class MachineManager(QObject): return bool(self._stacks_have_errors) @pyqtProperty(str, notify = globalContainerChanged) - @deprecated("use Cura.MachineManager.activeMachine.definition.getName instead", "4.1") + @deprecated("use Cura.MachineManager.activeMachine.definition.name instead", "4.1") def activeMachineDefinitionName(self) -> str: if self._global_container_stack: return self._global_container_stack.definition.getName() return "" @pyqtProperty(str, notify = globalContainerChanged) - @deprecated("use Cura.MachineManager.activeMachine.getName instead", "4.1") + @deprecated("use Cura.MachineManager.activeMachine.name instead", "4.1") def activeMachineName(self) -> str: if self._global_container_stack: return self._global_container_stack.getMetaDataEntry("group_name", self._global_container_stack.getName()) return "" @pyqtProperty(str, notify = globalContainerChanged) - @deprecated("use Cura.MachineManager.activeMachine.getId instead", "4.1") + @deprecated("use Cura.MachineManager.activeMachine.id instead", "4.1") def activeMachineId(self) -> str: if self._global_container_stack: return self._global_container_stack.getId() return "" @pyqtProperty(str, notify = globalContainerChanged) - @deprecated("use Cura.MachineManager.activeMachine.firmwareVersion instead", "4.1") def activeMachineFirmwareVersion(self) -> str: if not self._printer_output_devices: return "" return self._printer_output_devices[0].firmwareVersion @pyqtProperty(str, notify = globalContainerChanged) - @deprecated("use Cura.MachineManager.activeMachine.address instead", "4.1") def activeMachineAddress(self) -> str: if not self._printer_output_devices: return "" @@ -556,18 +554,15 @@ class MachineManager(QObject): return [] @pyqtProperty(bool, notify = printerConnectedStatusChanged) - @deprecated("use len(Cura.MachineManager.activeMachine.printers) instead", "4.1") def activeMachineIsGroup(self) -> bool: return bool(self._printer_output_devices) and len(self._printer_output_devices[0].printers) > 1 @pyqtProperty(bool, notify = printerConnectedStatusChanged) - @deprecated("use Cura.MachineManager.activeMachine.connectionType instead", "4.1") def activeMachineHasNetworkConnection(self) -> bool: # A network connection is only available if any output device is actually a network connected device. return any(d.connectionType == ConnectionType.NetworkConnection for d in self._printer_output_devices) @pyqtProperty(bool, notify = printerConnectedStatusChanged) - @deprecated("use Cura.MachineManager.activeMachine.connectionType instead", "4.1") def activeMachineHasCloudConnection(self) -> bool: # A cloud connection is only available if any output device actually is a cloud connected device. return any(d.connectionType == ConnectionType.CloudConnection for d in self._printer_output_devices) @@ -735,6 +730,7 @@ class MachineManager(QObject): return "" @pyqtProperty(str, notify = activeVariantChanged) + @deprecated("use Cura.activeStack.variant.id instead", "4.1") def activeVariantId(self) -> str: if self._active_container_stack: variant = self._active_container_stack.variant @@ -754,6 +750,7 @@ class MachineManager(QObject): return "" @pyqtProperty(str, notify = globalContainerChanged) + @deprecated("use Cura.activeMachine.definition.id instead", "4.1") def activeDefinitionId(self) -> str: if self._global_container_stack: return self._global_container_stack.definition.id @@ -818,19 +815,19 @@ class MachineManager(QObject): @pyqtProperty(bool, notify = globalContainerChanged) def hasMaterials(self) -> bool: if self._global_container_stack: - return Util.parseBool(self._global_container_stack.getMetaDataEntry("has_materials", False)) + return self._global_container_stack.getHasMaterials() return False @pyqtProperty(bool, notify = globalContainerChanged) def hasVariants(self) -> bool: if self._global_container_stack: - return Util.parseBool(self._global_container_stack.getMetaDataEntry("has_variants", False)) + return self._global_container_stack.getHasVariants() return False @pyqtProperty(bool, notify = globalContainerChanged) def hasVariantBuildplates(self) -> bool: if self._global_container_stack: - return Util.parseBool(self._global_container_stack.getMetaDataEntry("has_variant_buildplates", False)) + return self._global_container_stack.getHasVariantsBuildPlates() return False ## The selected buildplate is compatible if it is compatible with all the materials in all the extruders From c2a00d6b53923494196b4fd032f753e2083484fd Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 16 Apr 2019 10:53:06 +0200 Subject: [PATCH 4/4] Fix copy paste error Simple fix that caused crash for getHasVariantBuildplates --- cura/Settings/GlobalStack.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/Settings/GlobalStack.py b/cura/Settings/GlobalStack.py index df43b1c1f7..3ec73972dd 100755 --- a/cura/Settings/GlobalStack.py +++ b/cura/Settings/GlobalStack.py @@ -259,7 +259,7 @@ class GlobalStack(CuraContainerStack): return parseBool(self.getMetaDataEntry("has_variants", False)) def getHasVariantsBuildPlates(self) -> bool: - return parseBool(self._global_container_stack.getMetaDataEntry("has_variant_buildplates", False)) + return parseBool(self.getMetaDataEntry("has_variant_buildplates", False)) def getHasMachineQuality(self) -> bool: return parseBool(self.getMetaDataEntry("has_machine_quality", False))