mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 22:54:01 -06:00
Merge pull request #9488 from Ultimaker/CURA-8110_upgrader
Cura 8110 upgrader
This commit is contained in:
commit
b9f76ef9e4
10 changed files with 213 additions and 11 deletions
|
@ -458,15 +458,16 @@ class CuraApplication(QtApplication):
|
|||
|
||||
self._version_upgrade_manager.setCurrentVersions(
|
||||
{
|
||||
("quality", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.QualityInstanceContainer, "application/x-uranium-instancecontainer"),
|
||||
("quality_changes", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.QualityChangesInstanceContainer, "application/x-uranium-instancecontainer"),
|
||||
("intent", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.IntentInstanceContainer, "application/x-uranium-instancecontainer"),
|
||||
("machine_stack", GlobalStack.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.MachineStack, "application/x-cura-globalstack"),
|
||||
("extruder_train", ExtruderStack.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.ExtruderStack, "application/x-cura-extruderstack"),
|
||||
("preferences", Preferences.Version * 1000000 + self.SettingVersion): (Resources.Preferences, "application/x-uranium-preferences"),
|
||||
("user", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.UserInstanceContainer, "application/x-uranium-instancecontainer"),
|
||||
("definition_changes", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.DefinitionChangesContainer, "application/x-uranium-instancecontainer"),
|
||||
("variant", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.VariantInstanceContainer, "application/x-uranium-instancecontainer"),
|
||||
("quality", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.QualityInstanceContainer, "application/x-uranium-instancecontainer"),
|
||||
("quality_changes", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.QualityChangesInstanceContainer, "application/x-uranium-instancecontainer"),
|
||||
("intent", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.IntentInstanceContainer, "application/x-uranium-instancecontainer"),
|
||||
("machine_stack", GlobalStack.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.MachineStack, "application/x-cura-globalstack"),
|
||||
("extruder_train", ExtruderStack.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.ExtruderStack, "application/x-cura-extruderstack"),
|
||||
("preferences", Preferences.Version * 1000000 + self.SettingVersion): (Resources.Preferences, "application/x-uranium-preferences"),
|
||||
("user", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.UserInstanceContainer, "application/x-uranium-instancecontainer"),
|
||||
("definition_changes", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.DefinitionChangesContainer, "application/x-uranium-instancecontainer"),
|
||||
("variant", InstanceContainer.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.VariantInstanceContainer, "application/x-uranium-instancecontainer"),
|
||||
("setting_visibility", SettingVisibilityPresetsModel.Version * 1000000 + self.SettingVersion): (self.ResourceTypes.SettingVisibilityPreset, "application/x-uranium-preferences"),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ class SettingVisibilityPresetsModel(QObject):
|
|||
onItemsChanged = pyqtSignal()
|
||||
activePresetChanged = pyqtSignal()
|
||||
|
||||
Version = 2
|
||||
|
||||
def __init__(self, preferences: Preferences, parent = None) -> None:
|
||||
super().__init__(parent)
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ class DisplayProgressOnLCD(Script):
|
|||
current_time_string = "{:d}h{:02d}m{:02d}s".format(int(h), int(m), int(s))
|
||||
# And now insert that into the GCODE
|
||||
lines.insert(line_index, "M117 Time Left {}".format(current_time_string))
|
||||
else: # Must be m73.
|
||||
else:
|
||||
mins = int(60 * h + m + s / 30)
|
||||
lines.insert(line_index, "M73 R{}".format(mins))
|
||||
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
# Copyright (c) 2021 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import configparser
|
||||
from typing import Tuple, List
|
||||
import io
|
||||
|
||||
from UM.VersionUpgrade import VersionUpgrade
|
||||
|
||||
|
||||
class VersionUpgrade48to49(VersionUpgrade):
|
||||
_moved_visibility_settings = ["top_bottom_extruder_nr", "top_bottom_thickness", "top_thickness", "top_layers",
|
||||
"bottom_thickness", "bottom_layers", "ironing_enabled"]
|
||||
|
||||
def upgradePreferences(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
|
||||
"""
|
||||
Upgrades preferences to have the new version number.
|
||||
:param serialized: The original contents of the preferences file.
|
||||
:param filename: The file name of the preferences file.
|
||||
:return: A list of new file names, and a list of the new contents for
|
||||
those files.
|
||||
"""
|
||||
parser = configparser.ConfigParser(interpolation = None)
|
||||
parser.read_string(serialized)
|
||||
|
||||
# Update version number.
|
||||
parser["general"]["version"] = "7"
|
||||
|
||||
# Update visibility settings to include new top_bottom category
|
||||
parser["general"]["visible_settings"] += ";top_bottom"
|
||||
|
||||
if any([setting in parser["cura"]["categories_expanded"] for setting in self._moved_visibility_settings]):
|
||||
parser["cura"]["categories_expanded"] += ";top_bottom"
|
||||
|
||||
result = io.StringIO()
|
||||
parser.write(result)
|
||||
return [filename], [result.getvalue()]
|
||||
|
||||
def upgradeStack(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
|
||||
"""
|
||||
Upgrades stacks to have the new version number.
|
||||
|
||||
This updates the post-processing scripts with new parameters.
|
||||
:param serialized: The original contents of the stack.
|
||||
:param filename: The original file name of the stack.
|
||||
:return: A list of new file names, and a list of the new contents for
|
||||
those files.
|
||||
"""
|
||||
parser = configparser.ConfigParser(interpolation = None)
|
||||
parser.read_string(serialized)
|
||||
|
||||
# Update version number.
|
||||
if "general" not in parser:
|
||||
parser["general"] = {}
|
||||
parser["general"]["version"] = "5"
|
||||
|
||||
# Update Display Progress on LCD script parameters if present.
|
||||
if "post_processing_scripts" in parser["metadata"]:
|
||||
new_scripts_entries = []
|
||||
for script_str in parser["metadata"]["post_processing_scripts"].split("\n"):
|
||||
if not script_str:
|
||||
continue
|
||||
script_str = script_str.replace(r"\\\n", "\n").replace(r"\\\\", "\\\\") # Unescape escape sequences.
|
||||
script_parser = configparser.ConfigParser(interpolation=None)
|
||||
script_parser.optionxform = str # type: ignore # Don't transform the setting keys as they are case-sensitive.
|
||||
script_parser.read_string(script_str)
|
||||
|
||||
# Update Display Progress on LCD parameters.
|
||||
script_id = script_parser.sections()[0]
|
||||
if script_id == "DisplayProgressOnLCD":
|
||||
script_parser[script_id]["time_remaining_method"] = "m117" if script_parser[script_id]["time_remaining"] == "True" else "none"
|
||||
|
||||
script_io = io.StringIO()
|
||||
script_parser.write(script_io)
|
||||
script_str = script_io.getvalue()
|
||||
script_str = script_str.replace("\\\\", r"\\\\").replace("\n", r"\\\n") # Escape newlines because configparser sees those as section delimiters.
|
||||
new_scripts_entries.append(script_str)
|
||||
parser["metadata"]["post_processing_scripts"] = "\n".join(new_scripts_entries)
|
||||
|
||||
result = io.StringIO()
|
||||
parser.write(result)
|
||||
return [filename], [result.getvalue()]
|
||||
|
||||
def upgradeSettingVisibility(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
|
||||
"""
|
||||
Upgrades setting visibility to have a version number and move moved settings to a different category
|
||||
|
||||
:param serialized: The original contents of the stack.
|
||||
:param filename: The original file name of the stack.
|
||||
:return: A list of new file names, and a list of the new contents for
|
||||
those files.
|
||||
"""
|
||||
parser = configparser.ConfigParser(interpolation = None, allow_no_value=True)
|
||||
parser.read_string(serialized)
|
||||
|
||||
# add version number for the first time
|
||||
parser["general"]["version"] = "2"
|
||||
|
||||
if "top_bottom" not in parser:
|
||||
parser["top_bottom"] = {}
|
||||
|
||||
if "shell" in parser:
|
||||
for setting in parser["shell"]:
|
||||
if setting in self._moved_visibility_settings:
|
||||
parser["top_bottom"][setting] = None
|
||||
del parser["shell"][setting]
|
||||
|
||||
result = io.StringIO()
|
||||
parser.write(result)
|
||||
return [filename], [result.getvalue()]
|
44
plugins/VersionUpgrade/VersionUpgrade48to49/__init__.py
Normal file
44
plugins/VersionUpgrade/VersionUpgrade48to49/__init__.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
# Copyright (c) 2020 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from typing import Any, Dict, TYPE_CHECKING
|
||||
|
||||
from . import VersionUpgrade48to49
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from UM.Application import Application
|
||||
|
||||
upgrade = VersionUpgrade48to49.VersionUpgrade48to49()
|
||||
|
||||
def getMetaData() -> Dict[str, Any]:
|
||||
return {
|
||||
"version_upgrade": {
|
||||
# From To Upgrade function
|
||||
("preferences", 6000016): ("preferences", 7000016, upgrade.upgradePreferences),
|
||||
("machine_stack", 4000016): ("machine_stack", 5000016, upgrade.upgradeStack),
|
||||
("extruder_train", 4000016): ("extruder_train", 5000016, upgrade.upgradeStack),
|
||||
("setting_visibility", 1000000): ("setting_visibility", 2000016, upgrade.upgradeSettingVisibility),
|
||||
},
|
||||
"sources": {
|
||||
"preferences": {
|
||||
"get_version": upgrade.getCfgVersion,
|
||||
"location": {"."}
|
||||
},
|
||||
"machine_stack": {
|
||||
"get_version": upgrade.getCfgVersion,
|
||||
"location": {"./machine_instances"}
|
||||
},
|
||||
"extruder_train": {
|
||||
"get_version": upgrade.getCfgVersion,
|
||||
"location": {"./extruders"}
|
||||
},
|
||||
"setting_visibility": {
|
||||
"get_version": upgrade.getCfgVersion,
|
||||
"location": {"./setting_visibility"}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def register(app: "Application") -> Dict[str, Any]:
|
||||
return {"version_upgrade": upgrade}
|
8
plugins/VersionUpgrade/VersionUpgrade48to49/plugin.json
Normal file
8
plugins/VersionUpgrade/VersionUpgrade48to49/plugin.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "Version Upgrade 4.8 to 4.9",
|
||||
"author": "Ultimaker B.V.",
|
||||
"version": "1.0.0",
|
||||
"description": "Upgrades configurations from Cura 4.8 to Cura 4.9.",
|
||||
"api": "7.4.0",
|
||||
"i18n-catalog": "cura"
|
||||
}
|
|
@ -917,6 +917,40 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"VersionUpgrade47to48": {
|
||||
"package_info": {
|
||||
"package_id": "VersionUpgrade47to48",
|
||||
"package_type": "plugin",
|
||||
"display_name": "Version Upgrade 4.7.0 to 4.8.0",
|
||||
"description": "Upgrades configurations from Cura 4.7.0 to Cura 4.8.0",
|
||||
"package_version": "1.0.0",
|
||||
"sdk_version": "7.4.0",
|
||||
"website": "https://ultimaker.com",
|
||||
"author": {
|
||||
"author_id": "UltimakerPackages",
|
||||
"display_name": "Ultimaker B.V.",
|
||||
"email": "plugins@ultimaker.com",
|
||||
"website": "https://ultimaker.com"
|
||||
}
|
||||
}
|
||||
},
|
||||
"VersionUpgrade48to49": {
|
||||
"package_info": {
|
||||
"package_id": "VersionUpgrade48to49",
|
||||
"package_type": "plugin",
|
||||
"display_name": "Version Upgrade 4.8.0 to 4.9.0",
|
||||
"description": "Upgrades configurations from Cura 4.8.0 to Cura 4.9.0",
|
||||
"package_version": "1.0.0",
|
||||
"sdk_version": "7.4.0",
|
||||
"website": "https://ultimaker.com",
|
||||
"author": {
|
||||
"author_id": "UltimakerPackages",
|
||||
"display_name": "Ultimaker B.V.",
|
||||
"email": "plugins@ultimaker.com",
|
||||
"website": "https://ultimaker.com"
|
||||
}
|
||||
}
|
||||
},
|
||||
"X3DReader": {
|
||||
"package_info": {
|
||||
"package_id": "X3DReader",
|
||||
|
@ -1789,4 +1823,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[general]
|
||||
name = Advanced
|
||||
weight = 2
|
||||
version = 2
|
||||
|
||||
[machine_settings]
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[general]
|
||||
name = Basic
|
||||
weight = 1
|
||||
version = 2
|
||||
|
||||
[machine_settings]
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[general]
|
||||
name = Expert
|
||||
weight = 3
|
||||
version = 2
|
||||
|
||||
[machine_settings]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue