Move getMachinesWithDefinition to MachinesManager

CURA-9514, CURA-9277
This commit is contained in:
c.lamboo 2022-08-26 11:16:10 +02:00
parent 8b84db7059
commit f000b75661
3 changed files with 31 additions and 27 deletions

View file

@ -349,31 +349,6 @@ class GlobalStack(CuraContainerStack):
nameChanged = pyqtSignal()
name = pyqtProperty(str, fget=getName, fset=setName, notify=nameChanged)
def getMachinesWithDefinition(definition_id: str, online_only = False) -> List[ContainerStack]:
""" Fetches all container stacks that match definition_id.
:param definition_id: The id of the machine definition.
:return: A list of Containers that match definition_id
"""
from cura.CuraApplication import CuraApplication # In function to avoid circular import
application = CuraApplication.getInstance()
registry = application.getContainerRegistry()
machines = registry.findContainerStacks(type="machine")
# Filter machines that match definition
machines = filter(lambda machine: machine.definition.id == definition_id, machines)
# Filter only LAN and Cloud printers
machines = filter(lambda machine: ConnectionType.CloudConnection in machine.configuredConnectionTypes or
ConnectionType.NetworkConnection in machine.configuredConnectionTypes, machines)
if online_only:
# LAN printers can have is_online = False but should still be included, their online status is only checked when
# they are the active printer.
machines = filter(lambda machine: parseBool(machine.getMetaDataEntry("is_online", False) or
ConnectionType.NetworkConnection in machine.configuredConnectionTypes), machines)
return list(machines)
## private:
global_stack_mime = MimeType(
name = "application/x-cura-globalstack",