mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Fix legacy profile upgrade
CURA-4075 Only for single-extrusion machines just like before.
This commit is contained in:
parent
ea7ff05a3d
commit
7b4cb11240
2 changed files with 21 additions and 6 deletions
|
@ -2,6 +2,7 @@
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import configparser # For reading the legacy profile INI files.
|
import configparser # For reading the legacy profile INI files.
|
||||||
|
import io
|
||||||
import json # For reading the Dictionary of Doom.
|
import json # For reading the Dictionary of Doom.
|
||||||
import math # For mathematical operations included in the Dictionary of Doom.
|
import math # For mathematical operations included in the Dictionary of Doom.
|
||||||
import os.path # For concatenating the path to the plugin and the relative path to the Dictionary of Doom.
|
import os.path # For concatenating the path to the plugin and the relative path to the Dictionary of Doom.
|
||||||
|
@ -80,8 +81,7 @@ class LegacyProfileReader(ProfileReader):
|
||||||
|
|
||||||
parser = configparser.ConfigParser(interpolation = None)
|
parser = configparser.ConfigParser(interpolation = None)
|
||||||
try:
|
try:
|
||||||
with open(file_name) as f:
|
parser.read([file_name]) # Parse the INI file.
|
||||||
parser.readfp(f) # Parse the INI file.
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Logger.log("e", "Unable to open legacy profile %s: %s", file_name, str(e))
|
Logger.log("e", "Unable to open legacy profile %s: %s", file_name, str(e))
|
||||||
return None
|
return None
|
||||||
|
@ -138,7 +138,22 @@ class LegacyProfileReader(ProfileReader):
|
||||||
|
|
||||||
if len(profile.getAllKeys()) == 0:
|
if len(profile.getAllKeys()) == 0:
|
||||||
Logger.log("i", "A legacy profile was imported but everything evaluates to the defaults, creating an empty profile.")
|
Logger.log("i", "A legacy profile was imported but everything evaluates to the defaults, creating an empty profile.")
|
||||||
profile.setDirty(True)
|
|
||||||
profile.addMetaDataEntry("type", "quality_changes")
|
|
||||||
|
# We need to downgrade the container to version 1 (in Cura 2.1) so the upgrade system can correctly upgrade
|
||||||
|
# it to the latest version.
|
||||||
|
profile.addMetaDataEntry("type", "profile")
|
||||||
|
# don't know what quality_type it is based on, so use "normal" by default
|
||||||
profile.addMetaDataEntry("quality_type", "normal")
|
profile.addMetaDataEntry("quality_type", "normal")
|
||||||
return profile
|
profile.setDirty(True)
|
||||||
|
|
||||||
|
parser = configparser.ConfigParser(interpolation=None)
|
||||||
|
data = profile.serialize()
|
||||||
|
parser.read_string(data)
|
||||||
|
parser["general"]["version"] = "1"
|
||||||
|
stream = io.StringIO()
|
||||||
|
parser.write(stream)
|
||||||
|
data = stream.getvalue()
|
||||||
|
profile.deserialize(data)
|
||||||
|
|
||||||
|
return profile
|
||||||
|
|
|
@ -98,7 +98,7 @@ class Profile:
|
||||||
|
|
||||||
config.add_section("metadata")
|
config.add_section("metadata")
|
||||||
config.set("metadata", "quality_type", "normal") #This feature doesn't exist in 2.1 yet, so we don't know the actual quality type. For now, always base it on normal.
|
config.set("metadata", "quality_type", "normal") #This feature doesn't exist in 2.1 yet, so we don't know the actual quality type. For now, always base it on normal.
|
||||||
config.set("metadata", "type", "quality_changes")
|
config.set("metadata", "type", "quality")
|
||||||
if self._weight:
|
if self._weight:
|
||||||
config.set("metadata", "weight", str(self._weight))
|
config.set("metadata", "weight", str(self._weight))
|
||||||
if self._machine_variant_name:
|
if self._machine_variant_name:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue