mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-02 09:52:06 +08:00
Merge branch '3.2' of github.com:Ultimaker/cura into 3.2
This commit is contained in:
commit
b5856d6577
@ -189,7 +189,7 @@ class CrashHandler:
|
|||||||
|
|
||||||
json_metadata_file = os.path.join(directory, "plugin.json")
|
json_metadata_file = os.path.join(directory, "plugin.json")
|
||||||
try:
|
try:
|
||||||
with open(json_metadata_file, "r") as f:
|
with open(json_metadata_file, "r", encoding = "utf-8") as f:
|
||||||
try:
|
try:
|
||||||
metadata = json.loads(f.read())
|
metadata = json.loads(f.read())
|
||||||
module_version = metadata["version"]
|
module_version = metadata["version"]
|
||||||
@ -217,9 +217,9 @@ class CrashHandler:
|
|||||||
text_area = QTextEdit()
|
text_area = QTextEdit()
|
||||||
tmp_file_fd, tmp_file_path = tempfile.mkstemp(prefix = "cura-crash", text = True)
|
tmp_file_fd, tmp_file_path = tempfile.mkstemp(prefix = "cura-crash", text = True)
|
||||||
os.close(tmp_file_fd)
|
os.close(tmp_file_fd)
|
||||||
with open(tmp_file_path, "w") as f:
|
with open(tmp_file_path, "w", encoding = "utf-8") as f:
|
||||||
faulthandler.dump_traceback(f, all_threads=True)
|
faulthandler.dump_traceback(f, all_threads=True)
|
||||||
with open(tmp_file_path, "r") as f:
|
with open(tmp_file_path, "r", encoding = "utf-8") as f:
|
||||||
logdata = f.read()
|
logdata = f.read()
|
||||||
|
|
||||||
text_area.setText(logdata)
|
text_area.setText(logdata)
|
||||||
|
@ -486,7 +486,7 @@ class ContainerManager(QObject):
|
|||||||
container = container_type(container_id)
|
container = container_type(container_id)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(file_url, "rt") as f:
|
with open(file_url, "rt", encoding = "utf-8") as f:
|
||||||
container.deserialize(f.read())
|
container.deserialize(f.read())
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
return { "status": "error", "message": "Permission denied when trying to read the file"}
|
return { "status": "error", "message": "Permission denied when trying to read the file"}
|
||||||
|
@ -693,7 +693,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
instance_container = InstanceContainer(container_id)
|
instance_container = InstanceContainer(container_id)
|
||||||
with open(file_path, "r") as f:
|
with open(file_path, "r", encoding = "utf-8") as f:
|
||||||
serialized = f.read()
|
serialized = f.read()
|
||||||
instance_container.deserialize(serialized, file_path)
|
instance_container.deserialize(serialized, file_path)
|
||||||
self.addContainer(instance_container)
|
self.addContainer(instance_container)
|
||||||
|
@ -30,8 +30,8 @@ if not known_args["debug"]:
|
|||||||
if hasattr(sys, "frozen"):
|
if hasattr(sys, "frozen"):
|
||||||
dirpath = get_cura_dir_path()
|
dirpath = get_cura_dir_path()
|
||||||
os.makedirs(dirpath, exist_ok = True)
|
os.makedirs(dirpath, exist_ok = True)
|
||||||
sys.stdout = open(os.path.join(dirpath, "stdout.log"), "w")
|
sys.stdout = open(os.path.join(dirpath, "stdout.log"), "w", encoding = "utf-8")
|
||||||
sys.stderr = open(os.path.join(dirpath, "stderr.log"), "w")
|
sys.stderr = open(os.path.join(dirpath, "stderr.log"), "w", encoding = "utf-8")
|
||||||
|
|
||||||
import platform
|
import platform
|
||||||
import faulthandler
|
import faulthandler
|
||||||
|
@ -39,7 +39,7 @@ class CuraProfileReader(ProfileReader):
|
|||||||
|
|
||||||
except zipfile.BadZipFile:
|
except zipfile.BadZipFile:
|
||||||
# It must be an older profile from Cura 2.1.
|
# It must be an older profile from Cura 2.1.
|
||||||
with open(file_name, encoding="utf-8") as fhandle:
|
with open(file_name, encoding = "utf-8") as fhandle:
|
||||||
serialized = fhandle.read()
|
serialized = fhandle.read()
|
||||||
return [self._loadProfile(serialized, profile_id) for serialized, profile_id in self._upgradeProfile(serialized, file_name)]
|
return [self._loadProfile(serialized, profile_id) for serialized, profile_id in self._upgradeProfile(serialized, file_name)]
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class GCodeReader(MeshReader):
|
|||||||
|
|
||||||
# PreRead is used to get the correct flavor. If not, Marlin is set by default
|
# PreRead is used to get the correct flavor. If not, Marlin is set by default
|
||||||
def preRead(self, file_name, *args, **kwargs):
|
def preRead(self, file_name, *args, **kwargs):
|
||||||
with open(file_name, "r") as file:
|
with open(file_name, "r", encoding = "utf-8") as file:
|
||||||
for line in file:
|
for line in file:
|
||||||
if line[:len(self._flavor_keyword)] == self._flavor_keyword:
|
if line[:len(self._flavor_keyword)] == self._flavor_keyword:
|
||||||
try:
|
try:
|
||||||
|
@ -74,7 +74,7 @@ class VersionUpgrade22to24(VersionUpgrade):
|
|||||||
def __convertVariant(self, variant_path):
|
def __convertVariant(self, variant_path):
|
||||||
# Copy the variant to the machine_instances/*_settings.inst.cfg
|
# Copy the variant to the machine_instances/*_settings.inst.cfg
|
||||||
variant_config = configparser.ConfigParser(interpolation=None)
|
variant_config = configparser.ConfigParser(interpolation=None)
|
||||||
with open(variant_path, "r") as fhandle:
|
with open(variant_path, "r", encoding = "utf-8") as fhandle:
|
||||||
variant_config.read_file(fhandle)
|
variant_config.read_file(fhandle)
|
||||||
|
|
||||||
config_name = "Unknown Variant"
|
config_name = "Unknown Variant"
|
||||||
|
@ -59,6 +59,12 @@ _EMPTY_CONTAINER_DICT = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Renamed definition files
|
||||||
|
_RENAMED_DEFINITION_DICT = {
|
||||||
|
"jellybox": "imade3d_jellybox",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class VersionUpgrade30to31(VersionUpgrade):
|
class VersionUpgrade30to31(VersionUpgrade):
|
||||||
## Gets the version number from a CFG file in Uranium's 3.0 format.
|
## Gets the version number from a CFG file in Uranium's 3.0 format.
|
||||||
#
|
#
|
||||||
@ -122,6 +128,10 @@ class VersionUpgrade30to31(VersionUpgrade):
|
|||||||
if len(all_quality_changes) <= 1 and not parser.has_option("metadata", "extruder"):
|
if len(all_quality_changes) <= 1 and not parser.has_option("metadata", "extruder"):
|
||||||
self._createExtruderQualityChangesForSingleExtrusionMachine(filename, parser)
|
self._createExtruderQualityChangesForSingleExtrusionMachine(filename, parser)
|
||||||
|
|
||||||
|
# Check renamed definitions
|
||||||
|
if "definition" in parser["general"] and parser["general"]["definition"] in _RENAMED_DEFINITION_DICT:
|
||||||
|
parser["general"]["definition"] = _RENAMED_DEFINITION_DICT[parser["general"]["definition"]]
|
||||||
|
|
||||||
# Update version numbers
|
# Update version numbers
|
||||||
parser["general"]["version"] = "2"
|
parser["general"]["version"] = "2"
|
||||||
parser["metadata"]["setting_version"] = "4"
|
parser["metadata"]["setting_version"] = "4"
|
||||||
@ -156,6 +166,10 @@ class VersionUpgrade30to31(VersionUpgrade):
|
|||||||
if parser.has_option("containers", key) and parser["containers"][key] == "empty":
|
if parser.has_option("containers", key) and parser["containers"][key] == "empty":
|
||||||
parser["containers"][key] = specific_empty_container
|
parser["containers"][key] = specific_empty_container
|
||||||
|
|
||||||
|
# check renamed definition
|
||||||
|
if parser.has_option("containers", "6") and parser["containers"]["6"] in _RENAMED_DEFINITION_DICT:
|
||||||
|
parser["containers"]["6"] = _RENAMED_DEFINITION_DICT[parser["containers"]["6"]]
|
||||||
|
|
||||||
# Update version numbers
|
# Update version numbers
|
||||||
if "general" not in parser:
|
if "general" not in parser:
|
||||||
parser["general"] = {}
|
parser["general"] = {}
|
||||||
@ -219,6 +233,10 @@ class VersionUpgrade30to31(VersionUpgrade):
|
|||||||
extruder_quality_changes_parser["general"]["name"] = global_quality_changes["general"]["name"]
|
extruder_quality_changes_parser["general"]["name"] = global_quality_changes["general"]["name"]
|
||||||
extruder_quality_changes_parser["general"]["definition"] = global_quality_changes["general"]["definition"]
|
extruder_quality_changes_parser["general"]["definition"] = global_quality_changes["general"]["definition"]
|
||||||
|
|
||||||
|
# check renamed definition
|
||||||
|
if extruder_quality_changes_parser["general"]["definition"] in _RENAMED_DEFINITION_DICT:
|
||||||
|
extruder_quality_changes_parser["general"]["definition"] = _RENAMED_DEFINITION_DICT[extruder_quality_changes_parser["general"]["definition"]]
|
||||||
|
|
||||||
extruder_quality_changes_parser.add_section("metadata")
|
extruder_quality_changes_parser.add_section("metadata")
|
||||||
extruder_quality_changes_parser["metadata"]["quality_type"] = global_quality_changes["metadata"]["quality_type"]
|
extruder_quality_changes_parser["metadata"]["quality_type"] = global_quality_changes["metadata"]["quality_type"]
|
||||||
extruder_quality_changes_parser["metadata"]["type"] = global_quality_changes["metadata"]["type"]
|
extruder_quality_changes_parser["metadata"]["type"] = global_quality_changes["metadata"]["type"]
|
||||||
@ -231,5 +249,5 @@ class VersionUpgrade30to31(VersionUpgrade):
|
|||||||
|
|
||||||
quality_changes_dir = Resources.getPath(CuraApplication.ResourceTypes.QualityInstanceContainer)
|
quality_changes_dir = Resources.getPath(CuraApplication.ResourceTypes.QualityInstanceContainer)
|
||||||
|
|
||||||
with open(os.path.join(quality_changes_dir, extruder_quality_changes_filename), "w") as f:
|
with open(os.path.join(quality_changes_dir, extruder_quality_changes_filename), "w", encoding = "utf-8") as f:
|
||||||
f.write(extruder_quality_changes_output.getvalue())
|
f.write(extruder_quality_changes_output.getvalue())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user