mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-31 18:46:02 +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")
|
||||
try:
|
||||
with open(json_metadata_file, "r") as f:
|
||||
with open(json_metadata_file, "r", encoding = "utf-8") as f:
|
||||
try:
|
||||
metadata = json.loads(f.read())
|
||||
module_version = metadata["version"]
|
||||
@ -217,9 +217,9 @@ class CrashHandler:
|
||||
text_area = QTextEdit()
|
||||
tmp_file_fd, tmp_file_path = tempfile.mkstemp(prefix = "cura-crash", text = True)
|
||||
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)
|
||||
with open(tmp_file_path, "r") as f:
|
||||
with open(tmp_file_path, "r", encoding = "utf-8") as f:
|
||||
logdata = f.read()
|
||||
|
||||
text_area.setText(logdata)
|
||||
|
@ -486,7 +486,7 @@ class ContainerManager(QObject):
|
||||
container = container_type(container_id)
|
||||
|
||||
try:
|
||||
with open(file_url, "rt") as f:
|
||||
with open(file_url, "rt", encoding = "utf-8") as f:
|
||||
container.deserialize(f.read())
|
||||
except PermissionError:
|
||||
return { "status": "error", "message": "Permission denied when trying to read the file"}
|
||||
|
@ -693,7 +693,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
||||
continue
|
||||
|
||||
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()
|
||||
instance_container.deserialize(serialized, file_path)
|
||||
self.addContainer(instance_container)
|
||||
|
@ -30,8 +30,8 @@ if not known_args["debug"]:
|
||||
if hasattr(sys, "frozen"):
|
||||
dirpath = get_cura_dir_path()
|
||||
os.makedirs(dirpath, exist_ok = True)
|
||||
sys.stdout = open(os.path.join(dirpath, "stdout.log"), "w")
|
||||
sys.stderr = open(os.path.join(dirpath, "stderr.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", encoding = "utf-8")
|
||||
|
||||
import platform
|
||||
import faulthandler
|
||||
|
@ -39,7 +39,7 @@ class CuraProfileReader(ProfileReader):
|
||||
|
||||
except zipfile.BadZipFile:
|
||||
# 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()
|
||||
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
|
||||
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:
|
||||
if line[:len(self._flavor_keyword)] == self._flavor_keyword:
|
||||
try:
|
||||
|
@ -74,7 +74,7 @@ class VersionUpgrade22to24(VersionUpgrade):
|
||||
def __convertVariant(self, variant_path):
|
||||
# Copy the variant to the machine_instances/*_settings.inst.cfg
|
||||
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)
|
||||
|
||||
config_name = "Unknown Variant"
|
||||
|
@ -59,6 +59,12 @@ _EMPTY_CONTAINER_DICT = {
|
||||
}
|
||||
|
||||
|
||||
# Renamed definition files
|
||||
_RENAMED_DEFINITION_DICT = {
|
||||
"jellybox": "imade3d_jellybox",
|
||||
}
|
||||
|
||||
|
||||
class VersionUpgrade30to31(VersionUpgrade):
|
||||
## 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"):
|
||||
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
|
||||
parser["general"]["version"] = "2"
|
||||
parser["metadata"]["setting_version"] = "4"
|
||||
@ -156,6 +166,10 @@ class VersionUpgrade30to31(VersionUpgrade):
|
||||
if parser.has_option("containers", key) and parser["containers"][key] == "empty":
|
||||
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
|
||||
if "general" not in parser:
|
||||
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"]["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["metadata"]["quality_type"] = global_quality_changes["metadata"]["quality_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)
|
||||
|
||||
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())
|
||||
|
Loading…
x
Reference in New Issue
Block a user