mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 06:33:55 -06:00
Group printers by section (Connected Printers/Other Printers)
Cleanup redundant code. CURA-9514
This commit is contained in:
parent
b18080c332
commit
93e2bef303
4 changed files with 35 additions and 49 deletions
|
@ -1,6 +1,7 @@
|
|||
from typing import List
|
||||
|
||||
from UM.Settings.ContainerStack import ContainerStack
|
||||
from UM.Util import parseBool
|
||||
from cura.PrinterOutput.PrinterOutputDevice import ConnectionType
|
||||
from cura.Settings.GlobalStack import GlobalStack
|
||||
from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
|
||||
|
@ -15,7 +16,7 @@ class AbstractMachine(GlobalStack):
|
|||
self.setMetaDataEntry("type", "abstract_machine")
|
||||
|
||||
@classmethod
|
||||
def getMachines(cls, abstract_machine: ContainerStack) -> List[ContainerStack]:
|
||||
def getMachines(cls, abstract_machine: ContainerStack, online_only = False) -> List[ContainerStack]:
|
||||
""" Fetches all container stacks that match definition_id with an abstract machine.
|
||||
|
||||
:param abstractMachine: The abstract machine stack.
|
||||
|
@ -30,7 +31,12 @@ class AbstractMachine(GlobalStack):
|
|||
|
||||
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]
|
||||
machines = [machine for machine in registry.findContainerStacks(type="machine") if machine.definition.id == printer_type and ConnectionType.CloudConnection in machine.configuredConnectionTypes]
|
||||
|
||||
if online_only:
|
||||
machines = [machine for machine in machines if parseBool(machine.getMetaDataEntry("is_online", False))]
|
||||
|
||||
return machines
|
||||
|
||||
|
||||
## private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue