diff options
author | joeydelarago <joeydelarago@gmail.com> | 2022-08-23 11:35:00 +0300 |
---|---|---|
committer | joeydelarago <joeydelarago@gmail.com> | 2022-08-23 11:35:00 +0300 |
commit | 7ffa770fb47c2a4acbb0700378ef0b96ea519523 (patch) | |
tree | 63f4f5d1f19942576799682f9881a430b1dc9e81 /cura/Settings | |
parent | d1ae3136aa8c617967756a50c673030093782945 (diff) |
Searching container registry returns ContainerStacks.
Made typing more generic to work with an ContainerStack to compensate.
Made AbstractMachine getMachines a classmethod so it can be called with ContainerStacks.
CURA-9514
Diffstat (limited to 'cura/Settings')
-rw-r--r-- | cura/Settings/AbstractMachine.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/cura/Settings/AbstractMachine.py b/cura/Settings/AbstractMachine.py index a89201a294..a904058290 100644 --- a/cura/Settings/AbstractMachine.py +++ b/cura/Settings/AbstractMachine.py @@ -14,13 +14,22 @@ class AbstractMachine(GlobalStack): super().__init__(container_id) self.setMetaDataEntry("type", "abstract_machine") - def getMachines(self) -> List[ContainerStack]: - from cura.CuraApplication import CuraApplication + @classmethod + def getMachines(cls, abstract_machine: ContainerStack) -> List[ContainerStack]: + """ Fetches containers for all machines that match definition with an abstract machine. + :param abstractMachine: The abstract machine stack. + :return: A list of Containers or an empty list if stack is not an "abstract_machine" + """ + if not abstract_machine.getMetaDataEntry("type") == "abstract_machine": + return [] + + from cura.CuraApplication import CuraApplication # In function to avoid circular import application = CuraApplication.getInstance() registry = application.getContainerRegistry() - printer_type = self.definition.getId() + printer_type = abstract_machine.definition.getId() + return [machine for machine in registry.findContainerStacks(type="machine") if machine.definition.id == printer_type and ConnectionType.CloudConnection in machine.configuredConnectionTypes] |