Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLipu Fei <lipu.fei815@gmail.com>2019-07-11 15:27:46 +0300
committerLipu Fei <lipu.fei815@gmail.com>2019-07-11 15:27:49 +0300
commit6bb3e33c9e0ad50e8e647ebeff6f8bfa39d4fec9 (patch)
treebd6868a1b7b202ece6ab4b25ee023ded52480b3c /plugins/CuraProfileReader
parent483e343b38e8aeb2974199bdcf4c99f2f363e4f3 (diff)
Use VersionUpgradeManager to update the imported quality
CURA-6659
Diffstat (limited to 'plugins/CuraProfileReader')
-rw-r--r--plugins/CuraProfileReader/CuraProfileReader.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/plugins/CuraProfileReader/CuraProfileReader.py b/plugins/CuraProfileReader/CuraProfileReader.py
index daab73abc2..095c42319b 100644
--- a/plugins/CuraProfileReader/CuraProfileReader.py
+++ b/plugins/CuraProfileReader/CuraProfileReader.py
@@ -67,9 +67,10 @@ class CuraProfileReader(ProfileReader):
return []
version = int(parser["general"]["version"])
+ setting_version = int(parser["metadata"].get("setting_version", 0))
if InstanceContainer.Version != version:
name = parser["general"]["name"]
- return self._upgradeProfileVersion(serialized, name, version)
+ return self._upgradeProfileVersion(serialized, name, version, setting_version)
else:
return [(serialized, profile_id)]
@@ -98,19 +99,23 @@ class CuraProfileReader(ProfileReader):
# \param profile_id The name of the profile.
# \param source_version The profile version of 'serialized'.
# \return List of serialized profile strings and matching profile names.
- def _upgradeProfileVersion(self, serialized: str, profile_id: str, source_version: int) -> List[Tuple[str, str]]:
- converter_plugins = PluginRegistry.getInstance().getAllMetaData(filter = {"version_upgrade": {} }, active_only = True)
+ def _upgradeProfileVersion(self, serialized: str, profile_id: str, main_version: int, setting_version: int) -> List[Tuple[str, str]]:
+ source_version = main_version * 1000000 + setting_version
- source_format = ("profile", source_version)
- profile_convert_funcs = [plugin["version_upgrade"][source_format][2] for plugin in converter_plugins
- if source_format in plugin["version_upgrade"] and plugin["version_upgrade"][source_format][1] == InstanceContainer.Version]
+ from UM.VersionUpgradeManager import VersionUpgradeManager
+ results = VersionUpgradeManager.getInstance().updateFilesData("quality_changes", source_version, [serialized], [profile_id])
+ serialized = results.files_data[0]
- if not profile_convert_funcs:
- Logger.log("w", "Unable to find an upgrade path for the profile [%s]", profile_id)
+ parser = configparser.ConfigParser(interpolation = None)
+ parser.read_string(serialized)
+ if "general" not in parser:
+ Logger.log("w", "Missing required section 'general'.")
+ return []
+ if "version" not in parser["general"]:
+ Logger.log("w", "Missing required 'version' property")
return []
- filenames, outputs = profile_convert_funcs[0](serialized, profile_id)
- if filenames is None and outputs is None:
- Logger.log("w", "The conversion failed to return any usable data for [%s]", profile_id)
+ if int(parser["general"]["version"]) != InstanceContainer.Version:
+ Logger.log("e", "Failed to upgrade profile [%s]", profile_id)
return []
- return list(zip(outputs, filenames))
+ return [(serialized, profile_id)]