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:
authorc.lamboo <casperlamboo@gmail.com>2022-08-30 20:23:21 +0300
committerc.lamboo <casperlamboo@gmail.com>2022-08-30 20:23:21 +0300
commitad4bd64be42c4fc34a64cf5f120cec183b44cd53 (patch)
treec7299637b158178bc27e1e3a364bc9eb905bce54
parent576dbe5326e727ac9f7f988867a5ae990c15150f (diff)
Also upgrade `extruder_train`
As these are also instances of `GlobalStack` for extruders we have to include these in the update script CURA-9289
-rw-r--r--plugins/VersionUpgrade/VersionUpgrade50to52/VersionUpgrade50to52.py49
-rw-r--r--plugins/VersionUpgrade/VersionUpgrade50to52/__init__.py7
2 files changed, 40 insertions, 16 deletions
diff --git a/plugins/VersionUpgrade/VersionUpgrade50to52/VersionUpgrade50to52.py b/plugins/VersionUpgrade/VersionUpgrade50to52/VersionUpgrade50to52.py
index 208f7d25cb..9011bc3243 100644
--- a/plugins/VersionUpgrade/VersionUpgrade50to52/VersionUpgrade50to52.py
+++ b/plugins/VersionUpgrade/VersionUpgrade50to52/VersionUpgrade50to52.py
@@ -8,6 +8,8 @@ from UM.VersionUpgrade import VersionUpgrade
from cura.PrinterOutput.PrinterOutputDevice import ConnectionType
from cura.Settings.CuraStackBuilder import CuraStackBuilder
from cura.Settings.GlobalStack import GlobalStack
+from cura.Machines.ContainerTree import ContainerTree
+from cura.CuraApplication import CuraApplication
import io
@@ -17,25 +19,20 @@ class VersionUpgrade50to52(VersionUpgrade):
state they should be in at version 5.2.
"""
- def upgradeStack(self, serialized: str, original_filename: str) -> Tuple[List[str], List[str]]:
+ def upgradeMachine(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
"""
Upgrades container stacks to have the new version number.
Upgrades container stacks for FLSun Racer to change their profiles.
:param serialized: The original contents of the container stack.
- :param original_filename: The file name of the container stack.
+ :param filename: The file name of the container stack.
:return: A list of file names, and a list of the new contents for those files.
"""
+ [filename], [serialized] = self.upgradeStack(serialized, filename)
+ return [filename], [serialized]
parser = configparser.ConfigParser(interpolation = None)
parser.read_string(serialized)
- parser["metadata"]["setting_version"] = "6000020"
- parser["general"]["version"] = "6"
-
- original_file = io.StringIO()
- parser.write(original_file)
- original_data = original_file.getvalue()
-
connection_types = []
if "metadata" in parser and "connection_type" in parser["metadata"]:
connection_types = [int(connection_type) for connection_type in parser["metadata"]["connection_type"].split(",")]
@@ -43,16 +40,38 @@ class VersionUpgrade50to52(VersionUpgrade):
cloud_connection_types = ConnectionType.NetworkConnection, ConnectionType.CloudConnection
if not any(connection_type in cloud_connection_types for connection_type in connection_types):
- return [original_filename], [original_data]
+ return [filename], [serialized]
stack = GlobalStack("")
- stack.deserialize(original_data)
+ stack.deserialize(serialized)
definition_id = stack.getDefinition().getId()
abstract_machine = CuraStackBuilder.createAbstractMachine(definition_id)
if abstract_machine:
- file_name = f"{definition_id}_abstract_machine"
- data = abstract_machine.serialize()
- return [original_filename, file_name], [original_data, data]
+ abstract_machine_filename = abstract_machine_id
+ abstract_machine_serialized = abstract_machine.serialize()
+ return [filename, abstract_machine_filename], [serialized, abstract_machine_serialized]
+
+ return [filename], [serialized]
+
+ def upgradeStack(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
+ """
+ Upgrades container stacks to have the new version number.
+ Upgrades container stacks for FLSun Racer to change their profiles.
+ :param serialized: The original contents of the container stack.
+ :param filename: The file name of the container stack.
+ :return: A list of file names, and a list of the new contents for those files.
+ """
+
+ parser = configparser.ConfigParser(interpolation = None)
+ parser.read_string(serialized)
+
+ parser["metadata"]["setting_version"] = "6000020"
+ parser["general"]["version"] = "6"
+
+ file = io.StringIO()
+ parser.write(file)
+ data = file.getvalue()
+
+ return [filename], [data]
- return [original_filename], [original_data]
diff --git a/plugins/VersionUpgrade/VersionUpgrade50to52/__init__.py b/plugins/VersionUpgrade/VersionUpgrade50to52/__init__.py
index 4314fd0fd7..1d44de40fe 100644
--- a/plugins/VersionUpgrade/VersionUpgrade50to52/__init__.py
+++ b/plugins/VersionUpgrade/VersionUpgrade50to52/__init__.py
@@ -13,9 +13,14 @@ upgrade = VersionUpgrade50to52.VersionUpgrade50to52()
def getMetaData() -> Dict[str, Any]:
return {
"version_upgrade": {
- ("machine_stack", 5000020): ("machine_stack", 6000020, upgrade.upgradeStack),
+ ("machine_stack", 5000020): ("machine_stack", 6000020, upgrade.upgradeMachine),
+ ("extruder_train", 5000020): ("extruder_train", 6000020, upgrade.upgradeStack),
},
"sources": {
+ "extruder_train": {
+ "get_version": upgrade.getCfgVersion,
+ "location": {"./extruders"}
+ },
"machine_stack": {
"get_version": upgrade.getCfgVersion,
"location": {"./machine_instances"},