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:
authorDiego Prado Gesto <d.pradogesto@ultimaker.com>2018-04-23 12:29:18 +0300
committerDiego Prado Gesto <d.pradogesto@ultimaker.com>2018-04-23 12:29:18 +0300
commitb85b39ff355c735f86e31db618961c68481bdfbc (patch)
tree8b61ce4a6e790d59269d927b3d9171997b8b5092 /plugins/VersionUpgrade/VersionUpgrade32to33
parentd857541677bd7763d3828c1afb19702296ae4664 (diff)
CURA-5188 If the auto_slice option was enabled in previous version,
keep it like this in the new version. Since the default value of this preference changed, we don't want to confuse users that still use the auto_slice option. Those users with clean install or intalling Cura for the first time will have this preference disabled.
Diffstat (limited to 'plugins/VersionUpgrade/VersionUpgrade32to33')
-rw-r--r--plugins/VersionUpgrade/VersionUpgrade32to33/VersionUpgrade32to33.py28
-rw-r--r--plugins/VersionUpgrade/VersionUpgrade32to33/__init__.py6
2 files changed, 34 insertions, 0 deletions
diff --git a/plugins/VersionUpgrade/VersionUpgrade32to33/VersionUpgrade32to33.py b/plugins/VersionUpgrade/VersionUpgrade32to33/VersionUpgrade32to33.py
index 3de451632f..18851b82c7 100644
--- a/plugins/VersionUpgrade/VersionUpgrade32to33/VersionUpgrade32to33.py
+++ b/plugins/VersionUpgrade/VersionUpgrade32to33/VersionUpgrade32to33.py
@@ -85,6 +85,34 @@ class VersionUpgrade32to33(VersionUpgrade):
setting_version = int(parser.get("metadata", "setting_version", fallback = 0))
return format_version * 1000000 + setting_version
+ ## Upgrades a preferences file from version 3.2 to 3.3.
+ #
+ # \param serialised The serialised form of a preferences file.
+ # \param filename The name of the file to upgrade.
+ def upgradePreferences(self, serialised, filename):
+ parser = configparser.ConfigParser(interpolation = None)
+ parser.read_string(serialised)
+
+ # Update version numbers
+ if "general" not in parser:
+ parser["general"] = {}
+ parser["general"]["version"] = "6"
+ if "metadata" not in parser:
+ parser["metadata"] = {}
+ parser["metadata"]["setting_version"] = "4"
+
+ # The auto_slice preference changed its default value to "disabled" so if there is no value in previous versions,
+ # then it means the desired value is auto_slice "enabled"
+ if "auto_slice" not in parser["general"]:
+ parser["general"]["auto_slice"] = "True"
+ elif parser["general"]["auto_slice"] == "False": # If the value is False, then remove the entry
+ del parser["general"]["auto_slice"]
+
+ # Re-serialise the file.
+ output = io.StringIO()
+ parser.write(output)
+ return [filename], [output.getvalue()]
+
## Upgrades a container stack from version 3.2 to 3.3.
#
# \param serialised The serialised form of a container stack.
diff --git a/plugins/VersionUpgrade/VersionUpgrade32to33/__init__.py b/plugins/VersionUpgrade/VersionUpgrade32to33/__init__.py
index ae4bf7b2f9..5073be772d 100644
--- a/plugins/VersionUpgrade/VersionUpgrade32to33/__init__.py
+++ b/plugins/VersionUpgrade/VersionUpgrade32to33/__init__.py
@@ -9,6 +9,8 @@ def getMetaData():
return {
"version_upgrade": {
# From To Upgrade function
+ ("preferences", 5000004): ("preferences", 6000004, upgrade.upgradePreferences),
+
("machine_stack", 3000004): ("machine_stack", 4000004, upgrade.upgradeStack),
("extruder_train", 3000004): ("extruder_train", 4000004, upgrade.upgradeStack),
@@ -18,6 +20,10 @@ def getMetaData():
("variant", 2000004): ("variant", 3000004, upgrade.upgradeVariants)
},
"sources": {
+ "preferences": {
+ "get_version": upgrade.getCfgVersion,
+ "location": {"."}
+ },
"machine_stack": {
"get_version": upgrade.getCfgVersion,
"location": {"./machine_instances"}