mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 15:44:04 -06:00
Revert "Simplified upgrade funtion, typos, check extruder count"
This reverts commit fd6d3e76a3
.
CURA-4708
This commit is contained in:
parent
3fb3b5826f
commit
26a136f7c5
1 changed files with 64 additions and 59 deletions
|
@ -129,17 +129,12 @@ class VersionUpgrade30to31(VersionUpgrade):
|
||||||
if parser.has_option("values", "machine_nozzle_size"):
|
if parser.has_option("values", "machine_nozzle_size"):
|
||||||
machine_nozzle_size = parser["values"]["machine_nozzle_size"]
|
machine_nozzle_size = parser["values"]["machine_nozzle_size"]
|
||||||
|
|
||||||
machine_extruder_count = '1' # by default it is 1 and the value cannot be stored in the global stack
|
definition_name = parser["general"]["name"]
|
||||||
if parser.has_option("values", "machine_extruder_count"):
|
machine_extruders = self._getSingleExtrusionMachineExtruders(definition_name)
|
||||||
machine_extruder_count = parser["values"]["machine_extruder_count"]
|
|
||||||
|
|
||||||
if machine_extruder_count == '1':
|
#For single extuder machine we nee only first extruder
|
||||||
definition_name = parser["general"]["name"]
|
if len(machine_extruders) !=0:
|
||||||
machine_extruders = self._getSingleExtrusionMachineExtruders(definition_name)
|
if self._updateSingleExtuderDefinitionFile(machine_extruders, machine_nozzle_size):
|
||||||
|
|
||||||
# For single extruder machine we need only first extruder
|
|
||||||
if len(machine_extruders) !=0:
|
|
||||||
self._updateSingleExtruderDefinitionFile(machine_extruders, machine_nozzle_size)
|
|
||||||
parser.remove_option("values", "machine_nozzle_size")
|
parser.remove_option("values", "machine_nozzle_size")
|
||||||
|
|
||||||
# Update version numbers
|
# Update version numbers
|
||||||
|
@ -224,9 +219,9 @@ class VersionUpgrade30to31(VersionUpgrade):
|
||||||
|
|
||||||
machine_instances_dir = Resources.getPath(CuraApplication.ResourceTypes.MachineStack)
|
machine_instances_dir = Resources.getPath(CuraApplication.ResourceTypes.MachineStack)
|
||||||
|
|
||||||
machine_instance_id = None
|
machine_instances = []
|
||||||
|
|
||||||
# Find machine instances
|
#Find all machine instances
|
||||||
for item in os.listdir(machine_instances_dir):
|
for item in os.listdir(machine_instances_dir):
|
||||||
file_path = os.path.join(machine_instances_dir, item)
|
file_path = os.path.join(machine_instances_dir, item)
|
||||||
if not os.path.isfile(file_path):
|
if not os.path.isfile(file_path):
|
||||||
|
@ -247,51 +242,57 @@ class VersionUpgrade30to31(VersionUpgrade):
|
||||||
if not parser.has_option("general", "id"):
|
if not parser.has_option("general", "id"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
id = parser["general"]["id"]
|
machine_instances.append(parser)
|
||||||
if id + "_settings" != definition_name:
|
|
||||||
|
#Find for extruders
|
||||||
|
extruders_instances_dir = Resources.getPath(CuraApplication.ResourceTypes.ExtruderStack)
|
||||||
|
#"machine",[extruders]
|
||||||
|
extruder_instances_per_machine = {}
|
||||||
|
|
||||||
|
#Find all custom extruders for founded machines
|
||||||
|
for item in os.listdir(extruders_instances_dir):
|
||||||
|
file_path = os.path.join(extruders_instances_dir, item)
|
||||||
|
if not os.path.isfile(file_path):
|
||||||
continue
|
continue
|
||||||
else:
|
|
||||||
machine_instance_id = id
|
parser = configparser.ConfigParser(interpolation=None)
|
||||||
|
try:
|
||||||
|
parser.read([file_path])
|
||||||
|
except:
|
||||||
|
# skip, it is not a valid stack file
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not parser.has_option("metadata", "type"):
|
||||||
|
continue
|
||||||
|
if "extruder_train" != parser["metadata"]["type"]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not parser.has_option("metadata", "machine"):
|
||||||
|
continue
|
||||||
|
if not parser.has_option("metadata", "position"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
for machine_instace in machine_instances:
|
||||||
|
|
||||||
|
machine_id = machine_instace["general"]["id"]
|
||||||
|
if machine_id != parser["metadata"]["machine"]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if machine_id + "_settings" != definition_name:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if extruder_instances_per_machine.get(machine_id) is None:
|
||||||
|
extruder_instances_per_machine.update({machine_id:[]})
|
||||||
|
|
||||||
|
extruder_instances_per_machine.get(machine_id).append(parser)
|
||||||
|
#the extruder can be related only to one machine
|
||||||
break
|
break
|
||||||
|
|
||||||
if machine_instance_id is not None:
|
return extruder_instances_per_machine
|
||||||
|
|
||||||
extruders_instances_dir = Resources.getPath(CuraApplication.ResourceTypes.ExtruderStack)
|
#Find extruder defition at index 0 and update its values
|
||||||
#"machine",[extruders]
|
def _updateSingleExtuderDefinitionFile(self, extruder_instances_per_machine, machine_nozzle_size):
|
||||||
extruder_instances = []
|
|
||||||
|
|
||||||
# Find all custom extruders for found machines
|
|
||||||
for item in os.listdir(extruders_instances_dir):
|
|
||||||
file_path = os.path.join(extruders_instances_dir, item)
|
|
||||||
if not os.path.isfile(file_path):
|
|
||||||
continue
|
|
||||||
|
|
||||||
parser = configparser.ConfigParser(interpolation=None)
|
|
||||||
try:
|
|
||||||
parser.read([file_path])
|
|
||||||
except:
|
|
||||||
# skip, it is not a valid stack file
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not parser.has_option("metadata", "type"):
|
|
||||||
continue
|
|
||||||
if "extruder_train" != parser["metadata"]["type"]:
|
|
||||||
continue
|
|
||||||
|
|
||||||
if not parser.has_option("metadata", "machine"):
|
|
||||||
continue
|
|
||||||
if not parser.has_option("metadata", "position"):
|
|
||||||
continue
|
|
||||||
|
|
||||||
if machine_instance_id != parser["metadata"]["machine"]:
|
|
||||||
continue
|
|
||||||
|
|
||||||
extruder_instances.append(parser)
|
|
||||||
|
|
||||||
return extruder_instances
|
|
||||||
|
|
||||||
# Find extruder definition at index 0 and update its values
|
|
||||||
def _updateSingleExtruderDefinitionFile(self, extruder_instances_per_machine, machine_nozzle_size):
|
|
||||||
|
|
||||||
defintion_instances_dir = Resources.getPath(CuraApplication.ResourceTypes.DefinitionChangesContainer)
|
defintion_instances_dir = Resources.getPath(CuraApplication.ResourceTypes.DefinitionChangesContainer)
|
||||||
|
|
||||||
|
@ -311,15 +312,19 @@ class VersionUpgrade30to31(VersionUpgrade):
|
||||||
continue
|
continue
|
||||||
name = parser["general"]["name"]
|
name = parser["general"]["name"]
|
||||||
custom_extruder_at_0_position = None
|
custom_extruder_at_0_position = None
|
||||||
for extruder_instance in extruder_instances_per_machine:
|
for machine_extruders in extruder_instances_per_machine:
|
||||||
|
for extruder_instance in extruder_instances_per_machine[machine_extruders]:
|
||||||
|
|
||||||
definition_position = extruder_instance["metadata"]["position"]
|
if extruder_instance["general"]["id"] + "_settings" == name:
|
||||||
|
defition_position = extruder_instance["metadata"]["position"]
|
||||||
|
|
||||||
if definition_position == "0":
|
if defition_position == "0":
|
||||||
custom_extruder_at_0_position = extruder_instance
|
custom_extruder_at_0_position = extruder_instance
|
||||||
|
break
|
||||||
|
if custom_extruder_at_0_position is not None:
|
||||||
break
|
break
|
||||||
|
|
||||||
# If not null, then parsed file is for first extuder and then can be updated. I need to update only
|
#If not null, then parsed file is for first extuder and then can be updated. I need to update only
|
||||||
# first, because this update for single extuder machine
|
# first, because this update for single extuder machine
|
||||||
if custom_extruder_at_0_position is not None:
|
if custom_extruder_at_0_position is not None:
|
||||||
|
|
||||||
|
@ -369,4 +374,4 @@ 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") as f:
|
||||||
f.write(extruder_quality_changes_output.getvalue())
|
f.write(extruder_quality_changes_output.getvalue())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue