mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 07:03:56 -06:00
Fix upgrade from 2.5 to 2.6 to 2.7
CURA-3975 - Set Preferences setting_version in CuraApplication so Preferences can get upgraded correctly - Fix upgrade script for 2.5 to 2.6 - Fix upgrade script for 2.6 to 2.7 which relies on the upgrade of 2.5 to 2.6
This commit is contained in:
parent
3983da30aa
commit
5bf080950f
4 changed files with 91 additions and 6 deletions
|
@ -87,6 +87,50 @@ class VersionUpgrade26to27(VersionUpgrade):
|
|||
setting_version = int(parser.get("metadata", "setting_version", fallback = 0))
|
||||
return format_version * 1000000 + setting_version
|
||||
|
||||
## Upgrades a preferences file from version 2.6 to 2.7.
|
||||
#
|
||||
# \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"] = "4"
|
||||
|
||||
if "metadata" not in parser:
|
||||
parser["metadata"] = {}
|
||||
parser["metadata"]["setting_version"] = "2"
|
||||
|
||||
# Re-serialise the file.
|
||||
output = io.StringIO()
|
||||
parser.write(output)
|
||||
return [filename], [output.getvalue()]
|
||||
|
||||
## Upgrades a container file other than a container stack file from version 2.6 to 2.7.
|
||||
#
|
||||
# \param serialised The serialised form of a container file.
|
||||
# \param filename The name of the file to upgrade.
|
||||
def upgradeOtherContainer(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"] = "2"
|
||||
|
||||
if "metadata" not in parser:
|
||||
parser["metadata"] = {}
|
||||
parser["metadata"]["setting_version"] = "2"
|
||||
|
||||
# Re-serialise the file.
|
||||
output = io.StringIO()
|
||||
parser.write(output)
|
||||
return [filename], [output.getvalue()]
|
||||
|
||||
## Upgrades a container stack from version 2.6 to 2.7.
|
||||
#
|
||||
# \param serialised The serialised form of a container stack.
|
||||
|
@ -108,12 +152,15 @@ class VersionUpgrade26to27(VersionUpgrade):
|
|||
if not parser.has_section(each_section):
|
||||
parser.add_section(each_section)
|
||||
|
||||
# Change the version number in the file.
|
||||
parser["metadata"]["setting_version"] = str(CuraApplication.SettingVersion)
|
||||
|
||||
# Update version
|
||||
# Update version numbers
|
||||
if "general" not in parser:
|
||||
parser["general"] = {}
|
||||
parser["general"]["version"] = "3"
|
||||
|
||||
if "metadata" not in parser:
|
||||
parser["metadata"] = {}
|
||||
parser["metadata"]["setting_version"] = "2"
|
||||
|
||||
# Re-serialise the file.
|
||||
output = io.StringIO()
|
||||
parser.write(output)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue