diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index a410d10cc1..09604659cd 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -15,12 +15,11 @@ from UM.Settings.SettingFunction import SettingFunction from UM.Settings.ContainerStack import ContainerStack from UM.Settings.PropertyEvaluationContext import PropertyEvaluationContext -from typing import Optional, TYPE_CHECKING, Dict, List, Any, Union +from typing import Any, cast, Dict, List, Optional, TYPE_CHECKING, Union if TYPE_CHECKING: from cura.Settings.ExtruderStack import ExtruderStack from cura.Settings.GlobalStack import GlobalStack - from UM.Scene.SceneNode import SceneNode ## Manages all existing extruder stacks. @@ -380,7 +379,7 @@ class ExtruderManager(QObject): # If no extruder has the value, the list will contain the global value. @staticmethod def getExtruderValues(key: str) -> List[Any]: - global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack() + global_stack = cast(GlobalStack, cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()) #We know that there must be a global stack by the time you're requesting setting values. result = [] for extruder in ExtruderManager.getInstance().getActiveExtruderStacks(): @@ -415,7 +414,7 @@ class ExtruderManager(QObject): # If no extruder has the value, the list will contain the global value. @staticmethod def getDefaultExtruderValues(key: str) -> List[Any]: - global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack() + global_stack = cast(GlobalStack, cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()) #We know that there must be a global stack by the time you're requesting setting values. context = PropertyEvaluationContext(global_stack) context.context["evaluate_from_container_index"] = 1 # skip the user settings container context.context["override_operators"] = { @@ -482,7 +481,7 @@ class ExtruderManager(QObject): value = value(extruder) else: # Just a value from global. - value = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack().getProperty(key, "value") + value = cast(GlobalStack, cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()).getProperty(key, "value") return value @@ -511,7 +510,7 @@ class ExtruderManager(QObject): if isinstance(value, SettingFunction): value = value(extruder, context = context) else: # Just a value from global. - value = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack().getProperty(key, "value", context = context) + value = cast(GlobalStack, cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()).getProperty(key, "value", context = context) return value @@ -524,7 +523,7 @@ class ExtruderManager(QObject): # \return The effective value @staticmethod def getResolveOrValue(key: str) -> Any: - global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack() + global_stack = cast(GlobalStack, cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()) resolved_value = global_stack.getProperty(key, "value") return resolved_value @@ -538,7 +537,7 @@ class ExtruderManager(QObject): # \return The effective value @staticmethod def getDefaultResolveOrValue(key: str) -> Any: - global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack() + global_stack = cast(GlobalStack, cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()) context = PropertyEvaluationContext(global_stack) context.context["evaluate_from_container_index"] = 1 # skip the user settings container context.context["override_operators"] = { diff --git a/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py b/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py index 54b561c847..2430b35ea0 100644 --- a/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py +++ b/plugins/VersionUpgrade/VersionUpgrade25to26/VersionUpgrade25to26.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import configparser #To parse the files we need to upgrade and write the new files. @@ -9,8 +9,6 @@ from urllib.parse import quote_plus from UM.Resources import Resources from UM.VersionUpgrade import VersionUpgrade -from cura.CuraApplication import CuraApplication - _removed_settings = { #Settings that were removed in 2.5. "start_layers_at_same_position", "sub_div_rad_mult" @@ -152,7 +150,7 @@ class VersionUpgrade25to26(VersionUpgrade): ## Acquires the next unique extruder stack index number for the Custom FDM Printer. def _acquireNextUniqueCustomFdmPrinterExtruderStackIdIndex(self): - extruder_stack_dir = Resources.getPath(CuraApplication.ResourceTypes.ExtruderStack) + extruder_stack_dir = os.path.join(Resources.getDataStoragePath(), "extruders") file_name_list = os.listdir(extruder_stack_dir) file_name_list = [os.path.basename(file_name) for file_name in file_name_list] while True: @@ -173,7 +171,7 @@ class VersionUpgrade25to26(VersionUpgrade): def _checkCustomFdmPrinterHasExtruderStack(self, machine_id): # go through all extruders and make sure that this custom FDM printer has extruder stacks. - extruder_stack_dir = Resources.getPath(CuraApplication.ResourceTypes.ExtruderStack) + extruder_stack_dir = os.path.join(Resources.getDataStoragePath(), "extruders") has_extruders = False for item in os.listdir(extruder_stack_dir): file_path = os.path.join(extruder_stack_dir, item) @@ -245,9 +243,9 @@ class VersionUpgrade25to26(VersionUpgrade): parser.write(extruder_output) extruder_filename = quote_plus(stack_id) + ".extruder.cfg" - extruder_stack_dir = Resources.getPath(CuraApplication.ResourceTypes.ExtruderStack) - definition_changes_dir = Resources.getPath(CuraApplication.ResourceTypes.DefinitionChangesContainer) - user_settings_dir = Resources.getPath(CuraApplication.ResourceTypes.UserInstanceContainer) + extruder_stack_dir = os.path.join(Resources.getDataStoragePath(), "extruders") + definition_changes_dir = os.path.join(Resources.getDataStoragePath(), "definition_changes") + user_settings_dir = os.path.join(Resources.getDataStoragePath(), "user") with open(os.path.join(definition_changes_dir, definition_changes_filename), "w", encoding = "utf-8") as f: f.write(definition_changes_output.getvalue()) diff --git a/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py b/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py index 2037a0211d..dfa436e5bd 100644 --- a/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py +++ b/plugins/VersionUpgrade/VersionUpgrade26to27/VersionUpgrade26to27.py @@ -1,11 +1,10 @@ -# Copyright (c) 2017 Ultimaker B.V. +# Copyright (c) 2018 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. import configparser #To parse the files we need to upgrade and write the new files. import io #To serialise configparser output to a string. from UM.VersionUpgrade import VersionUpgrade -from cura.CuraApplication import CuraApplication # a dict of renamed quality profiles: : _renamed_quality_profiles = { diff --git a/tests/conftest.py b/tests/conftest.py index 77d215815a..ad0bc609ee 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -6,6 +6,8 @@ import unittest.mock import pytest +import Arcus #Prevents error: "PyCapsule_GetPointer called with incorrect name" with conflicting SIP configurations between Arcus and PyQt: Import Arcus and Savitar first! +import Savitar from UM.Qt.QtApplication import QtApplication #QtApplication import is required, even though it isn't used. from cura.CuraApplication import CuraApplication from cura.MachineActionManager import MachineActionManager