本文整理汇总了Python中UM.Settings.ContainerStack.ContainerStack.getName方法的典型用法代码示例。如果您正苦于以下问题:Python ContainerStack.getName方法的具体用法?Python ContainerStack.getName怎么用?Python ContainerStack.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UM.Settings.ContainerStack.ContainerStack
的用法示例。
在下文中一共展示了ContainerStack.getName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_roundtrip_stack
# 需要导入模块: from UM.Settings.ContainerStack import ContainerStack [as 别名]
# 或者: from UM.Settings.ContainerStack.ContainerStack import getName [as 别名]
def test_roundtrip_stack(tmpdir, process_count, loaded_container_registry):
definition = loaded_container_registry.findDefinitionContainers(id = "multiple_settings")[0]
instances = loaded_container_registry.findInstanceContainers(id = "setting_values")[0]
container_stack = ContainerStack("test_stack")
container_stack.setName("Test Container Stack")
container_stack.addMetaDataEntry("test", "test")
container_stack.addContainer(definition)
container_stack.addContainer(instances)
temp_file = tmpdir.join("container_stack_test")
mp_run(process_count, write_data, temp_file, container_stack)
assert len(list(tmpdir.listdir())) == 1
results = mp_run(process_count, read_data, temp_file)
for result in results:
deserialized_stack = ContainerStack("test_stack")
deserialized_stack.deserialize(result)
assert deserialized_stack.getName() == container_stack.getName()
assert deserialized_stack.getMetaData() == container_stack.getMetaData()
assert deserialized_stack.getBottom() == container_stack.getBottom()
assert deserialized_stack.getTop() == container_stack.getTop()
示例2: _test_serialize_cycle
# 需要导入模块: from UM.Settings.ContainerStack import ContainerStack [as 别名]
# 或者: from UM.Settings.ContainerStack.ContainerStack import getName [as 别名]
def _test_serialize_cycle(container_stack):
name = container_stack.getName()
metadata = container_stack.getMetaData()
containers = container_stack.getContainers()
serialised = container_stack.serialize()
container_stack = ContainerStack(uuid.uuid4().int) # Completely fresh container stack.
container_stack.deserialize(serialised)
#ID and nextStack are allowed to be different.
assert name == container_stack.getName()
assert metadata == container_stack.getMetaData()
assert containers == container_stack.getContainers()
示例3: read
# 需要导入模块: from UM.Settings.ContainerStack import ContainerStack [as 别名]
# 或者: from UM.Settings.ContainerStack.ContainerStack import getName [as 别名]
#.........这里部分代码省略.........
self._container_registry.addContainer(container)
# Get the stack(s) saved in the workspace.
Logger.log("d", "Workspace loading is checking stacks containers...")
container_stack_files = [name for name in cura_file_names if name.endswith(self._container_stack_suffix)]
global_stack = None
extruder_stacks = []
container_stacks_added = []
try:
for container_stack_file in container_stack_files:
container_id = self._stripFileToId(container_stack_file)
# Check if a stack by this ID already exists;
container_stacks = self._container_registry.findContainerStacks(id=container_id)
if container_stacks:
stack = container_stacks[0]
if self._resolve_strategies["machine"] == "override":
container_stacks[0].deserialize(archive.open(container_stack_file).read().decode("utf-8"))
elif self._resolve_strategies["machine"] == "new":
new_id = self.getNewId(container_id)
stack = ContainerStack(new_id)
stack.deserialize(archive.open(container_stack_file).read().decode("utf-8"))
# Ensure a unique ID and name
stack._id = new_id
# Extruder stacks are "bound" to a machine. If we add the machine as a new one, the id of the
# bound machine also needs to change.
if stack.getMetaDataEntry("machine", None):
stack.setMetaDataEntry("machine", self.getNewId(stack.getMetaDataEntry("machine")))
if stack.getMetaDataEntry("type") != "extruder_train":
# Only machines need a new name, stacks may be non-unique
stack.setName(self._container_registry.uniqueName(stack.getName()))
container_stacks_added.append(stack)
self._container_registry.addContainer(stack)
else:
Logger.log("w", "Resolve strategy of %s for machine is not supported", self._resolve_strategies["machine"])
else:
stack = ContainerStack(container_id)
# Deserialize stack by converting read data from bytes to string
stack.deserialize(archive.open(container_stack_file).read().decode("utf-8"))
container_stacks_added.append(stack)
self._container_registry.addContainer(stack)
if stack.getMetaDataEntry("type") == "extruder_train":
extruder_stacks.append(stack)
else:
global_stack = stack
except:
Logger.log("W", "We failed to serialize the stack. Trying to clean up.")
# Something went really wrong. Try to remove any data that we added.
for container in containers_to_add:
self._container_registry.getInstance().removeContainer(container.getId())
for container in container_stacks_added:
self._container_registry.getInstance().removeContainer(container.getId())
return None
if self._resolve_strategies["machine"] == "new":
# A new machine was made, but it was serialized with the wrong user container. Fix that now.
for container in user_instance_containers:
extruder_id = container.getMetaDataEntry("extruder", None)
if extruder_id:
for extruder in extruder_stacks: