From dc2126983458964973eb4a7de23c1fe0f0227e32 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 9 May 2019 14:52:08 +0200 Subject: [PATCH 01/19] Add first machines endpoint Contributes to CL-1331 --- cura/API/Machines.py | 76 ++++++++++++++++++++++++++++++++++++++++++++ cura/API/__init__.py | 8 +++++ 2 files changed, 84 insertions(+) create mode 100644 cura/API/Machines.py diff --git a/cura/API/Machines.py b/cura/API/Machines.py new file mode 100644 index 0000000000..f02bc1c463 --- /dev/null +++ b/cura/API/Machines.py @@ -0,0 +1,76 @@ +# Copyright (c) 2019 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. + +from typing import Optional, Dict, TYPE_CHECKING +from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty +from UM.i18n import i18nCatalog +from UM.Logger import Logger +if TYPE_CHECKING: + from cura.CuraApplication import CuraApplication + +i18n_catalog = i18nCatalog("cura") + +## The account API provides a version-proof bridge to use Ultimaker Accounts +# +# Usage: +# ``` +# from cura.API import CuraAPI +# api = CuraAPI() +# api.machines.addOutputDeviceToCurrentMachine() +# ``` +# +class Machines(QObject): + + def __init__(self, application: "CuraApplication", parent = None) -> None: + super().__init__(parent) + self._application = application + + ## Add an output device to the current machine. + # In practice, this means: + # - Setting the output device's network key in the current machine's metadata + # - Adding the output device's connection type to the current machine's configured connection + # types. + # TODO: CHANGE TO HOSTNAME + @pyqtSlot(QObject) + def addOutputDeviceToCurrentMachine(self, output_device): + if not output_device: + return + + Logger.log("d", + "Attempting to set the network key of the active machine to %s", + output_device.key) + + global_container_stack = self._application.getGlobalContainerStack() + if not global_container_stack: + return + + metadata = global_container_stack.getMetaData() + + if "um_network_key" in metadata: # Global stack already had a connection, but it's changed. + old_network_key = metadata["um_network_key"] + # Since we might have a bunch of hidden stacks, we also need to change it there. + metadata_filter = {"um_network_key": old_network_key} + containers = self._application.getContainerRegistry().findContainerStacks( + type = "machine", **metadata_filter) + + for container in containers: + container.setMetaDataEntry("um_network_key", output_device.key) + + # Delete old authentication data. + Logger.log("d", "Removing old authentication id %s for device %s", + global_container_stack.getMetaDataEntry("network_authentication_id", None), + output_device.key) + + container.removeMetaDataEntry("network_authentication_id") + container.removeMetaDataEntry("network_authentication_key") + + # Ensure that these containers do know that they are configured for the given + # connection type (can be more than one type; e.g. LAN & Cloud) + container.addConfiguredConnectionType(output_device.connectionType.value) + + else: # Global stack didn't have a connection yet, configure it. + global_container_stack.setMetaDataEntry("um_network_key", output_device.key) + global_container_stack.addConfiguredConnectionType(output_device.connectionType.value) + + return None + diff --git a/cura/API/__init__.py b/cura/API/__init__.py index b3e702263a..8e73680dfe 100644 --- a/cura/API/__init__.py +++ b/cura/API/__init__.py @@ -6,6 +6,7 @@ from PyQt5.QtCore import QObject, pyqtProperty from cura.API.Backups import Backups from cura.API.Interface import Interface +from cura.API.Machines import Machines from cura.API.Account import Account if TYPE_CHECKING: @@ -44,6 +45,9 @@ class CuraAPI(QObject): # Backups API self._backups = Backups(self._application) + # Machines API + self._machines = Machines(self._application) + # Interface API self._interface = Interface(self._application) @@ -58,6 +62,10 @@ class CuraAPI(QObject): def backups(self) -> "Backups": return self._backups + @property + def machines(self) -> "Machines": + return self._machines + @property def interface(self) -> "Interface": return self._interface From 20a9b65ea581aa1ad73b8dc834b8f8cb4fdaced9 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 9 May 2019 14:54:24 +0200 Subject: [PATCH 02/19] Use API endpoint for machine association Contributes to CL-1331 and CL-1323 --- .../src/DiscoverUM3Action.py | 24 +++++----- .../src/UM3OutputDevicePlugin.py | 45 ++++--------------- 2 files changed, 23 insertions(+), 46 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py index b67f4d7185..1ad3d1d96f 100644 --- a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py +++ b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py @@ -34,7 +34,10 @@ class DiscoverUM3Action(MachineAction): self.__additional_components_view = None #type: Optional[QObject] - CuraApplication.getInstance().engineCreatedSignal.connect(self._createAdditionalComponentsView) + self._application = CuraApplication.getInstance() + self._api = self._application.getCuraAPI() + + self._application.engineCreatedSignal.connect(self._createAdditionalComponentsView) self._last_zero_conf_event_time = time.time() #type: float @@ -50,7 +53,7 @@ class DiscoverUM3Action(MachineAction): def startDiscovery(self): if not self._network_plugin: Logger.log("d", "Starting device discovery.") - self._network_plugin = CuraApplication.getInstance().getOutputDeviceManager().getOutputDevicePlugin("UM3NetworkPrinting") + self._network_plugin = self._application.getOutputDeviceManager().getOutputDevicePlugin("UM3NetworkPrinting") self._network_plugin.discoveredDevicesChanged.connect(self._onDeviceDiscoveryChanged) self.discoveredDevicesChanged.emit() @@ -108,11 +111,11 @@ class DiscoverUM3Action(MachineAction): @pyqtSlot(str) def setGroupName(self, group_name: str) -> None: Logger.log("d", "Attempting to set the group name of the active machine to %s", group_name) - global_container_stack = CuraApplication.getInstance().getGlobalContainerStack() + global_container_stack = self._application.getGlobalContainerStack() if global_container_stack: # Update a GlobalStacks in the same group with the new group name. group_id = global_container_stack.getMetaDataEntry("group_id") - machine_manager = CuraApplication.getInstance().getMachineManager() + machine_manager = self._application.getMachineManager() for machine in machine_manager.getMachinesInGroup(group_id): machine.setMetaDataEntry("group_name", group_name) @@ -126,13 +129,14 @@ class DiscoverUM3Action(MachineAction): # Associates the currently active machine with the given printer device. The network connection information will be # stored into the metadata of the currently active machine. @pyqtSlot(QObject) - def associateActiveMachineWithPrinterDevice(self, printer_device: Optional["PrinterOutputDevice"]) -> None: + def associateActiveMachineWithPrinterDevice(self, output_device: Optional["PrinterOutputDevice"]) -> None: + self._api.machines.addOutputDeviceToCurrentMachine(output_device) if self._network_plugin: - self._network_plugin.associateActiveMachineWithPrinterDevice(printer_device) + self._network_plugin.refreshConnections() @pyqtSlot(result = str) def getStoredKey(self) -> str: - global_container_stack = CuraApplication.getInstance().getGlobalContainerStack() + global_container_stack = self._application.getGlobalContainerStack() if global_container_stack: meta_data = global_container_stack.getMetaData() if "um_network_key" in meta_data: @@ -154,7 +158,7 @@ class DiscoverUM3Action(MachineAction): @pyqtSlot() def loadConfigurationFromPrinter(self) -> None: - machine_manager = CuraApplication.getInstance().getMachineManager() + machine_manager = self._application.getMachineManager() hotend_ids = machine_manager.printerOutputDevices[0].hotendIds for index in range(len(hotend_ids)): machine_manager.printerOutputDevices[0].hotendIdChanged.emit(index, hotend_ids[index]) @@ -170,10 +174,10 @@ class DiscoverUM3Action(MachineAction): if not plugin_path: return path = os.path.join(plugin_path, "resources/qml/UM3InfoComponents.qml") - self.__additional_components_view = CuraApplication.getInstance().createQmlComponent(path, {"manager": self}) + self.__additional_components_view = self._application.createQmlComponent(path, {"manager": self}) if not self.__additional_components_view: Logger.log("w", "Could not create ui components for UM3.") return # Create extra components - CuraApplication.getInstance().addAdditionalComponent("monitorButtons", self.__additional_components_view.findChild(QObject, "networkPrinterConnectButton")) + self._application.addAdditionalComponent("monitorButtons", self.__additional_components_view.findChild(QObject, "networkPrinterConnectButton")) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index 41c76dc4c0..fd4149c5c7 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -67,11 +67,11 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): def __init__(self): super().__init__() - self._zero_conf = None self._zero_conf_browser = None self._application = CuraApplication.getInstance() + self._api = self._application.getCuraAPI() # Create a cloud output device manager that abstracts all cloud connection logic away. self._cloud_output_device_manager = CloudOutputDeviceManager() @@ -96,7 +96,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): self._cluster_api_prefix = "/cluster-api/v" + self._cluster_api_version + "/" # Get list of manual instances from preferences - self._preferences = CuraApplication.getInstance().getPreferences() + self._preferences = self._application.getPreferences() self._preferences.addPreference("um3networkprinting/manual_instances", "") # A comma-separated list of ip adresses or hostnames @@ -116,7 +116,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): self._service_changed_request_thread = Thread(target=self._handleOnServiceChangedRequests, daemon=True) self._service_changed_request_thread.start() - self._account = self._application.getCuraAPI().account + self._account = self._api.account # Check if cloud flow is possible when user logs in self._account.loginStateChanged.connect(self.checkCloudFlowIsPossible) @@ -170,7 +170,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): self.resetLastManualDevice() def refreshConnections(self): - active_machine = CuraApplication.getInstance().getGlobalContainerStack() + active_machine = self._application.getGlobalContainerStack() if not active_machine: return @@ -197,7 +197,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): return if self._discovered_devices[key].isConnected(): # Sometimes the status changes after changing the global container and maybe the device doesn't belong to this machine - um_network_key = CuraApplication.getInstance().getGlobalContainerStack().getMetaDataEntry("um_network_key") + um_network_key = self._application.getGlobalContainerStack().getMetaDataEntry("um_network_key") if key == um_network_key: self.getOutputDeviceManager().addOutputDevice(self._discovered_devices[key]) self.checkCloudFlowIsPossible(None) @@ -273,38 +273,11 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): self._application.getMachineManager().addMachine(machine_type_id, group_name) # connect the new machine to that network printer - self.associateActiveMachineWithPrinterDevice(discovered_device) + self._api.machines.addOutputDeviceToCurrentMachine(discovered_device) # ensure that the connection states are refreshed. self.refreshConnections() - def associateActiveMachineWithPrinterDevice(self, printer_device: Optional["PrinterOutputDevice"]) -> None: - if not printer_device: - return - - Logger.log("d", "Attempting to set the network key of the active machine to %s", printer_device.key) - - machine_manager = CuraApplication.getInstance().getMachineManager() - global_container_stack = machine_manager.activeMachine - if not global_container_stack: - return - - for machine in machine_manager.getMachinesInGroup(global_container_stack.getMetaDataEntry("group_id")): - machine.setMetaDataEntry("um_network_key", printer_device.key) - machine.setMetaDataEntry("group_name", printer_device.name) - - # Delete old authentication data. - Logger.log("d", "Removing old authentication id %s for device %s", - global_container_stack.getMetaDataEntry("network_authentication_id", None), printer_device.key) - - machine.removeMetaDataEntry("network_authentication_id") - machine.removeMetaDataEntry("network_authentication_key") - - # Ensure that these containers do know that they are configured for network connection - machine.addConfiguredConnectionType(printer_device.connectionType.value) - - self.refreshConnections() - - def _checkManualDevice(self, address: str) -> "QNetworkReply": + def _checkManualDevice(self, address: str) -> None: # Check if a UM3 family device exists at this address. # If a printer responds, it will replace the preliminary printer created above # origin=manual is for tracking back the origin of the call @@ -426,7 +399,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): self._discovered_devices[device.getId()] = device self.discoveredDevicesChanged.emit() - global_container_stack = CuraApplication.getInstance().getGlobalContainerStack() + global_container_stack = self._application.getGlobalContainerStack() if global_container_stack and device.getId() == global_container_stack.getMetaDataEntry("um_network_key"): # Ensure that the configured connection type is set. global_container_stack.addConfiguredConnectionType(device.connectionType.value) @@ -446,7 +419,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): self._service_changed_request_event.wait(timeout = 5.0) # Stop if the application is shutting down - if CuraApplication.getInstance().isShuttingDown(): + if self._application.isShuttingDown(): return self._service_changed_request_event.clear() From 26ab359a938627c71329afb1ed74eeee6a3c2ab2 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 9 May 2019 16:01:44 +0200 Subject: [PATCH 03/19] Add more endpoints to machines API - getCurrentMachine - setCurrentMachineGroupName - updateCurrentMachineConfiguration Also shortened `global_container_stack` to `global_stack` since every stack is a container stack. Contributes to CL-1331 --- cura/API/Machines.py | 74 ++++++++++++++++--- .../src/DiscoverUM3Action.py | 42 ++++------- 2 files changed, 75 insertions(+), 41 deletions(-) diff --git a/cura/API/Machines.py b/cura/API/Machines.py index f02bc1c463..4cd89420c7 100644 --- a/cura/API/Machines.py +++ b/cura/API/Machines.py @@ -25,6 +25,58 @@ class Machines(QObject): super().__init__(parent) self._application = application + @pyqtSlot(result=dict) + def getCurrentMachine(self) -> dict: + global_stack = self._application.getGlobalContainerStack() + if global_stack: + metadata = global_stack.getMetaData() + + # Since Cura doesn't have a machine class, we're going to make a fake one to make our + # lives a little bit easier. + fake_machine = { + "hostname": "", + "group_id": global_stack.getMetaDataEntry("group_id") if "group_id" in metadata else "", + "group_name": global_stack.getMetaDataEntry("group_name") if "group_name" in metadata else "", + "um_network_key": global_stack.getMetaDataEntry("um_network_key") if "um_network_key" in metadata else "", + "configuration": {} + } + return fake_machine + + ## Set the current machine's friendy name. + # This is the same as "group name" since we use "group" and "current machine" interchangeably. + # TODO: Maybe make this "friendly name" to distinguish from "hostname"? + @pyqtSlot(str) + def setCurrentMachineGroupName(self, group_name: str): + Logger.log("d", "Attempting to set the group name of the active machine to %s", group_name) + global_stack = self._application.getGlobalContainerStack() + if global_stack: + # Update a GlobalStacks in the same group with the new group name. + group_id = global_stack.getMetaDataEntry("group_id") + machine_manager = self._application.getMachineManager() + for machine in machine_manager.getMachinesInGroup(group_id): + machine.setMetaDataEntry("group_name", group_name) + + # Set the default value for "hidden", which is used when you have a group with multiple types of printers + global_stack.setMetaDataEntry("hidden", False) + + ## Set the current machine's configuration from an (optional) output device. + # If no output device is given, the first one available on the machine will be used. + # NOTE: Group and machine are used interchangeably. + @pyqtSlot(QObject) + def updateCurrentMachineConfiguration(self, output_device: Optional["PrinterOutputDevice"]) -> None: + + if output_device is None: + machine_manager = self._application.getMachineManager() + output_device = machine_manager.printerOutputDevices[0] + + hotend_ids = output_device.hotendIds + for index in range(len(hotend_ids)): + output_device.hotendIdChanged.emit(index, hotend_ids[index]) + + material_ids = output_device.materialIds + for index in range(len(material_ids)): + output_device.materialIdChanged.emit(index, material_ids[index]) + ## Add an output device to the current machine. # In practice, this means: # - Setting the output device's network key in the current machine's metadata @@ -32,33 +84,31 @@ class Machines(QObject): # types. # TODO: CHANGE TO HOSTNAME @pyqtSlot(QObject) - def addOutputDeviceToCurrentMachine(self, output_device): + def addOutputDeviceToCurrentMachine(self, output_device: "PrinterOutputDevice") -> None: if not output_device: return - Logger.log("d", "Attempting to set the network key of the active machine to %s", output_device.key) - - global_container_stack = self._application.getGlobalContainerStack() - if not global_container_stack: + global_stack = self._application.getGlobalContainerStack() + if not global_stack: return + metadata = global_stack.getMetaData() - metadata = global_container_stack.getMetaData() - - if "um_network_key" in metadata: # Global stack already had a connection, but it's changed. + # Global stack already had a connection, but it's changed. + if "um_network_key" in metadata: old_network_key = metadata["um_network_key"] + # Since we might have a bunch of hidden stacks, we also need to change it there. metadata_filter = {"um_network_key": old_network_key} containers = self._application.getContainerRegistry().findContainerStacks( type = "machine", **metadata_filter) - for container in containers: container.setMetaDataEntry("um_network_key", output_device.key) # Delete old authentication data. Logger.log("d", "Removing old authentication id %s for device %s", - global_container_stack.getMetaDataEntry("network_authentication_id", None), + global_stack.getMetaDataEntry("network_authentication_id", None), output_device.key) container.removeMetaDataEntry("network_authentication_id") @@ -69,8 +119,8 @@ class Machines(QObject): container.addConfiguredConnectionType(output_device.connectionType.value) else: # Global stack didn't have a connection yet, configure it. - global_container_stack.setMetaDataEntry("um_network_key", output_device.key) - global_container_stack.addConfiguredConnectionType(output_device.connectionType.value) + global_stack.setMetaDataEntry("um_network_key", output_device.key) + global_stack.addConfiguredConnectionType(output_device.connectionType.value) return None diff --git a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py index 1ad3d1d96f..04f3c7f25a 100644 --- a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py +++ b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py @@ -108,63 +108,47 @@ class DiscoverUM3Action(MachineAction): else: return [] + # TODO: Should be able to just access the API from QML. @pyqtSlot(str) def setGroupName(self, group_name: str) -> None: - Logger.log("d", "Attempting to set the group name of the active machine to %s", group_name) - global_container_stack = self._application.getGlobalContainerStack() - if global_container_stack: - # Update a GlobalStacks in the same group with the new group name. - group_id = global_container_stack.getMetaDataEntry("group_id") - machine_manager = self._application.getMachineManager() - for machine in machine_manager.getMachinesInGroup(group_id): - machine.setMetaDataEntry("group_name", group_name) - - # Set the default value for "hidden", which is used when you have a group with multiple types of printers - global_container_stack.setMetaDataEntry("hidden", False) - + self._api.machines.setCurrentMachineGroupName(group_name) if self._network_plugin: - # Ensure that the connection states are refreshed. self._network_plugin.refreshConnections() - # Associates the currently active machine with the given printer device. The network connection information will be - # stored into the metadata of the currently active machine. + # TODO: Should be able to just access the API from QML. @pyqtSlot(QObject) def associateActiveMachineWithPrinterDevice(self, output_device: Optional["PrinterOutputDevice"]) -> None: self._api.machines.addOutputDeviceToCurrentMachine(output_device) if self._network_plugin: self._network_plugin.refreshConnections() + # TODO: Better naming needed. Stored where? This is current machine's key. + # TODO: CHANGE TO HOSTNAME + # TODO: Should be able to just access the API from QML. @pyqtSlot(result = str) def getStoredKey(self) -> str: - global_container_stack = self._application.getGlobalContainerStack() - if global_container_stack: - meta_data = global_container_stack.getMetaData() - if "um_network_key" in meta_data: - return global_container_stack.getMetaDataEntry("um_network_key") - - return "" + current_machine = self._api.machines.getCurrentMachine() + return current_machine["um_network_key"] + # TODO: CHANGE TO HOSTNAME @pyqtSlot(result = str) def getLastManualEntryKey(self) -> str: if self._network_plugin: return self._network_plugin.getLastManualDevice() return "" + # TODO: Better naming needed. Exists where? On the current machine? On all machines? + # TODO: CHANGE TO HOSTNAME @pyqtSlot(str, result = bool) def existsKey(self, key: str) -> bool: metadata_filter = {"um_network_key": key} containers = CuraContainerRegistry.getInstance().findContainerStacks(type="machine", **metadata_filter) return bool(containers) + # TODO: Should be able to just access the API from QML. @pyqtSlot() def loadConfigurationFromPrinter(self) -> None: - machine_manager = self._application.getMachineManager() - hotend_ids = machine_manager.printerOutputDevices[0].hotendIds - for index in range(len(hotend_ids)): - machine_manager.printerOutputDevices[0].hotendIdChanged.emit(index, hotend_ids[index]) - material_ids = machine_manager.printerOutputDevices[0].materialIds - for index in range(len(material_ids)): - machine_manager.printerOutputDevices[0].materialIdChanged.emit(index, material_ids[index]) + self._api.machines.updateCurrentMachineConfiguration() def _createAdditionalComponentsView(self) -> None: Logger.log("d", "Creating additional ui components for UM3.") From 03fd9da4177cb1ff4f65f70c469686331ad662fc Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 9 May 2019 16:19:39 +0200 Subject: [PATCH 04/19] Always return a fake machine, even if empty Contributes to CL-1331 --- cura/API/Machines.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/cura/API/Machines.py b/cura/API/Machines.py index 4cd89420c7..3fd7d9138a 100644 --- a/cura/API/Machines.py +++ b/cura/API/Machines.py @@ -27,20 +27,26 @@ class Machines(QObject): @pyqtSlot(result=dict) def getCurrentMachine(self) -> dict: + # Since Cura doesn't have a machine class, we're going to make a fake one to make our + # lives a little bit easier. + fake_machine = { + "hostname": "", + "group_id": "", + "group_name": "", + "um_network_key": "", + "configuration": {} + } global_stack = self._application.getGlobalContainerStack() if global_stack: metadata = global_stack.getMetaData() - - # Since Cura doesn't have a machine class, we're going to make a fake one to make our - # lives a little bit easier. - fake_machine = { - "hostname": "", - "group_id": global_stack.getMetaDataEntry("group_id") if "group_id" in metadata else "", - "group_name": global_stack.getMetaDataEntry("group_name") if "group_name" in metadata else "", - "um_network_key": global_stack.getMetaDataEntry("um_network_key") if "um_network_key" in metadata else "", - "configuration": {} - } - return fake_machine + if "group_id" in metadata: + fake_machine["group_id"] = global_stack.getMetaDataEntry("group_id") + if "group_name" in metadata: + fake_machine["group_name"] = global_stack.getMetaDataEntry("group_name") + if "um_network_key" in metadata: + fake_machine["um_network_key"] = global_stack.getMetaDataEntry("um_network_key") + + return fake_machine ## Set the current machine's friendy name. # This is the same as "group name" since we use "group" and "current machine" interchangeably. From b3276777b71de78d9a43ba12dfa44042a877d9eb Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 9 May 2019 16:19:59 +0200 Subject: [PATCH 05/19] Expose machines API to QML Contributes to CL-1331 --- cura/API/Machines.py | 4 +- cura/API/__init__.py | 2 +- .../resources/qml/DiscoverUM3Action.qml | 9 ++-- .../src/DiscoverUM3Action.py | 41 +++++++++++-------- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/cura/API/Machines.py b/cura/API/Machines.py index 3fd7d9138a..cc67d8ab54 100644 --- a/cura/API/Machines.py +++ b/cura/API/Machines.py @@ -25,8 +25,8 @@ class Machines(QObject): super().__init__(parent) self._application = application - @pyqtSlot(result=dict) - def getCurrentMachine(self) -> dict: + @pyqtSlot(result="QVariantMap") + def getCurrentMachine(self) -> "QVariantMap": # Since Cura doesn't have a machine class, we're going to make a fake one to make our # lives a little bit easier. fake_machine = { diff --git a/cura/API/__init__.py b/cura/API/__init__.py index 8e73680dfe..0a5eab9535 100644 --- a/cura/API/__init__.py +++ b/cura/API/__init__.py @@ -62,7 +62,7 @@ class CuraAPI(QObject): def backups(self) -> "Backups": return self._backups - @property + @pyqtProperty(QObject) def machines(self) -> "Machines": return self._machines diff --git a/plugins/UM3NetworkPrinting/resources/qml/DiscoverUM3Action.qml b/plugins/UM3NetworkPrinting/resources/qml/DiscoverUM3Action.qml index ecec87ef02..c250c1feb4 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/DiscoverUM3Action.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/DiscoverUM3Action.qml @@ -27,13 +27,14 @@ Cura.MachineAction { var printerKey = base.selectedDevice.key var printerName = base.selectedDevice.name // TODO To change when the groups have a name - if (manager.getStoredKey() != printerKey) + if (Cura.API.machines.getCurrentMachine()["um_network_key"] != printerKey) { // Check if there is another instance with the same key if (!manager.existsKey(printerKey)) { - manager.associateActiveMachineWithPrinterDevice(base.selectedDevice) - manager.setGroupName(printerName) // TODO To change when the groups have a name + Cura.API.machines.addOutputDeviceToCurrentMachine(base.selectedDevice) + Cura.API.machines.setCurrentMachineGroupName(printerName) // TODO To change when the groups have a name + manager.refreshConnections() completed() } else @@ -156,7 +157,7 @@ Cura.MachineAction var selectedKey = manager.getLastManualEntryKey() // If there is no last manual entry key, then we select the stored key (if any) if (selectedKey == "") - selectedKey = manager.getStoredKey() + selectedKey = Cura.API.machines.getCurrentMachine()["um_network_key"] for(var i = 0; i < model.length; i++) { if(model[i].key == selectedKey) { diff --git a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py index 04f3c7f25a..6b6e466219 100644 --- a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py +++ b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py @@ -108,27 +108,32 @@ class DiscoverUM3Action(MachineAction): else: return [] - # TODO: Should be able to just access the API from QML. - @pyqtSlot(str) - def setGroupName(self, group_name: str) -> None: - self._api.machines.setCurrentMachineGroupName(group_name) + # # TODO: Should be able to just access the API from QML. + # @pyqtSlot(str) + # def setGroupName(self, group_name: str) -> None: + # self._api.machines.setCurrentMachineGroupName(group_name) + # if self._network_plugin: + # self._network_plugin.refreshConnections() + + # # TODO: Should be able to just access the API from QML. + # @pyqtSlot(QObject) + # def associateActiveMachineWithPrinterDevice(self, output_device: Optional["PrinterOutputDevice"]) -> None: + # self._api.machines.addOutputDeviceToCurrentMachine(output_device) + + @pyqtSlot() + def refreshConnections(self) -> None: if self._network_plugin: self._network_plugin.refreshConnections() - # TODO: Should be able to just access the API from QML. - @pyqtSlot(QObject) - def associateActiveMachineWithPrinterDevice(self, output_device: Optional["PrinterOutputDevice"]) -> None: - self._api.machines.addOutputDeviceToCurrentMachine(output_device) - if self._network_plugin: - self._network_plugin.refreshConnections() - - # TODO: Better naming needed. Stored where? This is current machine's key. - # TODO: CHANGE TO HOSTNAME - # TODO: Should be able to just access the API from QML. - @pyqtSlot(result = str) - def getStoredKey(self) -> str: - current_machine = self._api.machines.getCurrentMachine() - return current_machine["um_network_key"] + # # TODO: Better naming needed. Stored where? This is current machine's key. + # # TODO: CHANGE TO HOSTNAME + # # TODO: Should be able to just access the API from QML. + # @pyqtSlot(result = str) + # def getStoredKey(self) -> str: + # current_machine = self._api.machines.getCurrentMachine() + # if current_machine: + # return current_machine["um_network_key"] + # return "" # TODO: CHANGE TO HOSTNAME @pyqtSlot(result = str) From f7ef24819dab49f7059efe6fe922428b1c3d5960 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 9 May 2019 16:23:12 +0200 Subject: [PATCH 06/19] Remove unused code I'm not sure why loadConfigurationFromPrinter is not used... but it's not. Contributes to CL-1331 --- .../src/DiscoverUM3Action.py | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py index 6b6e466219..76d898b840 100644 --- a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py +++ b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py @@ -108,33 +108,11 @@ class DiscoverUM3Action(MachineAction): else: return [] - # # TODO: Should be able to just access the API from QML. - # @pyqtSlot(str) - # def setGroupName(self, group_name: str) -> None: - # self._api.machines.setCurrentMachineGroupName(group_name) - # if self._network_plugin: - # self._network_plugin.refreshConnections() - - # # TODO: Should be able to just access the API from QML. - # @pyqtSlot(QObject) - # def associateActiveMachineWithPrinterDevice(self, output_device: Optional["PrinterOutputDevice"]) -> None: - # self._api.machines.addOutputDeviceToCurrentMachine(output_device) - @pyqtSlot() def refreshConnections(self) -> None: if self._network_plugin: self._network_plugin.refreshConnections() - # # TODO: Better naming needed. Stored where? This is current machine's key. - # # TODO: CHANGE TO HOSTNAME - # # TODO: Should be able to just access the API from QML. - # @pyqtSlot(result = str) - # def getStoredKey(self) -> str: - # current_machine = self._api.machines.getCurrentMachine() - # if current_machine: - # return current_machine["um_network_key"] - # return "" - # TODO: CHANGE TO HOSTNAME @pyqtSlot(result = str) def getLastManualEntryKey(self) -> str: @@ -150,11 +128,6 @@ class DiscoverUM3Action(MachineAction): containers = CuraContainerRegistry.getInstance().findContainerStacks(type="machine", **metadata_filter) return bool(containers) - # TODO: Should be able to just access the API from QML. - @pyqtSlot() - def loadConfigurationFromPrinter(self) -> None: - self._api.machines.updateCurrentMachineConfiguration() - def _createAdditionalComponentsView(self) -> None: Logger.log("d", "Creating additional ui components for UM3.") From d391ec4e6bcdeb1b1f4e669b17a0b2b836093c4a Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 9 May 2019 16:41:01 +0200 Subject: [PATCH 07/19] Comments Contributes to CL-1331 --- cura/API/Machines.py | 1 + plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py | 1 + 2 files changed, 2 insertions(+) diff --git a/cura/API/Machines.py b/cura/API/Machines.py index cc67d8ab54..c7b2b492c2 100644 --- a/cura/API/Machines.py +++ b/cura/API/Machines.py @@ -68,6 +68,7 @@ class Machines(QObject): ## Set the current machine's configuration from an (optional) output device. # If no output device is given, the first one available on the machine will be used. # NOTE: Group and machine are used interchangeably. + # NOTE: This doesn't seem to be used anywhere. Maybe delete? @pyqtSlot(QObject) def updateCurrentMachineConfiguration(self, output_device: Optional["PrinterOutputDevice"]) -> None: diff --git a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py index 76d898b840..5d608ed546 100644 --- a/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py +++ b/plugins/UM3NetworkPrinting/src/DiscoverUM3Action.py @@ -113,6 +113,7 @@ class DiscoverUM3Action(MachineAction): if self._network_plugin: self._network_plugin.refreshConnections() + # TODO: Improve naming # TODO: CHANGE TO HOSTNAME @pyqtSlot(result = str) def getLastManualEntryKey(self) -> str: From df6898ae4576ac39290d7d0f690965bae00eb941 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Thu, 9 May 2019 16:41:15 +0200 Subject: [PATCH 08/19] Add connection_types to fake machine Contributes to CL-1331 --- cura/API/Machines.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cura/API/Machines.py b/cura/API/Machines.py index c7b2b492c2..2e08f2bd07 100644 --- a/cura/API/Machines.py +++ b/cura/API/Machines.py @@ -34,7 +34,8 @@ class Machines(QObject): "group_id": "", "group_name": "", "um_network_key": "", - "configuration": {} + "configuration": {}, + "connection_types": [] } global_stack = self._application.getGlobalContainerStack() if global_stack: @@ -45,6 +46,8 @@ class Machines(QObject): fake_machine["group_name"] = global_stack.getMetaDataEntry("group_name") if "um_network_key" in metadata: fake_machine["um_network_key"] = global_stack.getMetaDataEntry("um_network_key") + + fake_machine["connection_types"] = global_stack.configuredConnectionTypes return fake_machine From 8b25816b1ba02b78a8317ccebe08f46372d28ecb Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 13 May 2019 14:44:39 +0200 Subject: [PATCH 09/19] Fix typo and white space Contributes to CL-1331 --- plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index fd4149c5c7..0010c893ea 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -167,8 +167,9 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): for address in self._manual_instances: if address: self.addManualDevice(address) - self.resetLastManualDevice() - + self.resetLastManu + + # TODO: CHANGE TO HOSTNAME def refreshConnections(self): active_machine = self._application.getGlobalContainerStack() if not active_machine: @@ -272,8 +273,10 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): key, group_name, machine_type_id) self._application.getMachineManager().addMachine(machine_type_id, group_name) + # connect the new machine to that network printer self._api.machines.addOutputDeviceToCurrentMachine(discovered_device) + # ensure that the connection states are refreshed. self.refreshConnections() @@ -285,6 +288,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): name_request = QNetworkRequest(url) return self._network_manager.get(name_request) + ## This is the function which handles the above network request's reply when it comes back. def _onNetworkRequestFinished(self, reply: "QNetworkReply") -> None: reply_url = reply.url().toString() From 177e031f4fcb72f93247d03d4cf6b676550ffcd2 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 13 May 2019 14:45:02 +0200 Subject: [PATCH 10/19] Add "lite" Machine class Contributes to CL-1331 --- cura/API/Machines.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/cura/API/Machines.py b/cura/API/Machines.py index 2e08f2bd07..63c5bdfede 100644 --- a/cura/API/Machines.py +++ b/cura/API/Machines.py @@ -18,7 +18,18 @@ i18n_catalog = i18nCatalog("cura") # api = CuraAPI() # api.machines.addOutputDeviceToCurrentMachine() # ``` -# + +## Since Cura doesn't have a machine class, we're going to make a fake one to make our lives a +# little bit easier. +class Machine(): + def __init__(self) -> None: + self.hostname = "" # type: str + self.group_id = "" # type: str + self.group_name = "" # type: str + self.um_network_key = "" # type: str + self.configuration = {} # type: Dict + self.connection_types = [] # type: List + class Machines(QObject): def __init__(self, application: "CuraApplication", parent = None) -> None: @@ -27,27 +38,18 @@ class Machines(QObject): @pyqtSlot(result="QVariantMap") def getCurrentMachine(self) -> "QVariantMap": - # Since Cura doesn't have a machine class, we're going to make a fake one to make our - # lives a little bit easier. - fake_machine = { - "hostname": "", - "group_id": "", - "group_name": "", - "um_network_key": "", - "configuration": {}, - "connection_types": [] - } + fake_machine = Machine() # type: Machine global_stack = self._application.getGlobalContainerStack() if global_stack: metadata = global_stack.getMetaData() if "group_id" in metadata: - fake_machine["group_id"] = global_stack.getMetaDataEntry("group_id") + fake_machine.group_id = global_stack.getMetaDataEntry("group_id") if "group_name" in metadata: - fake_machine["group_name"] = global_stack.getMetaDataEntry("group_name") + fake_machine.group_name = global_stack.getMetaDataEntry("group_name") if "um_network_key" in metadata: - fake_machine["um_network_key"] = global_stack.getMetaDataEntry("um_network_key") + fake_machine.um_network_key = global_stack.getMetaDataEntry("um_network_key") - fake_machine["connection_types"] = global_stack.configuredConnectionTypes + fake_machine.connection_types = global_stack.configuredConnectionTypes return fake_machine From b8ab9f6398cfccf25e75d0616d52c491653991be Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 13 May 2019 14:53:58 +0200 Subject: [PATCH 11/19] Fix typings Contributes to CL-1331 --- cura/API/Machines.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cura/API/Machines.py b/cura/API/Machines.py index 63c5bdfede..19057cc127 100644 --- a/cura/API/Machines.py +++ b/cura/API/Machines.py @@ -7,6 +7,7 @@ from UM.i18n import i18nCatalog from UM.Logger import Logger if TYPE_CHECKING: from cura.CuraApplication import CuraApplication + from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice i18n_catalog = i18nCatalog("cura") @@ -37,7 +38,7 @@ class Machines(QObject): self._application = application @pyqtSlot(result="QVariantMap") - def getCurrentMachine(self) -> "QVariantMap": + def getCurrentMachine(self) -> Machine: fake_machine = Machine() # type: Machine global_stack = self._application.getGlobalContainerStack() if global_stack: From e39769cc00e6e5dd4c756ad1b4da0a4ff75dacd1 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 13 May 2019 14:59:23 +0200 Subject: [PATCH 12/19] Fix last typing issue Contributes to CL-1331 --- cura/API/Machines.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/API/Machines.py b/cura/API/Machines.py index 19057cc127..13f8b3ae6f 100644 --- a/cura/API/Machines.py +++ b/cura/API/Machines.py @@ -1,7 +1,7 @@ # Copyright (c) 2019 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from typing import Optional, Dict, TYPE_CHECKING +from typing import Optional, Dict, List, TYPE_CHECKING from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty from UM.i18n import i18nCatalog from UM.Logger import Logger From c4ca133b40e76972fcf623efbd12b68a32305ef6 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Mon, 13 May 2019 15:39:29 +0200 Subject: [PATCH 13/19] Update UM3OutputDevicePlugin.py Contributes to CL-1331 --- plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index 0010c893ea..79d360cee2 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -280,7 +280,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): # ensure that the connection states are refreshed. self.refreshConnections() - def _checkManualDevice(self, address: str) -> None: + def _checkManualDevice(self, address: str): # Check if a UM3 family device exists at this address. # If a printer responds, it will replace the preliminary printer created above # origin=manual is for tracking back the origin of the call From c7f6351903b775cff29a4eeb3d7cc53430e475a9 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 15 May 2019 10:09:27 +0200 Subject: [PATCH 14/19] Add typings Contributes to CL-1331 --- cura/API/Machines.py | 6 +++--- plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cura/API/Machines.py b/cura/API/Machines.py index 13f8b3ae6f..4a5761cd9b 100644 --- a/cura/API/Machines.py +++ b/cura/API/Machines.py @@ -28,8 +28,8 @@ class Machine(): self.group_id = "" # type: str self.group_name = "" # type: str self.um_network_key = "" # type: str - self.configuration = {} # type: Dict - self.connection_types = [] # type: List + self.configuration = {} # type: Dict[str, any] + self.connection_types = [] # type: List["ConnectionType"] class Machines(QObject): @@ -58,7 +58,7 @@ class Machines(QObject): # This is the same as "group name" since we use "group" and "current machine" interchangeably. # TODO: Maybe make this "friendly name" to distinguish from "hostname"? @pyqtSlot(str) - def setCurrentMachineGroupName(self, group_name: str): + def setCurrentMachineGroupName(self, group_name: str) -> None: Logger.log("d", "Attempting to set the group name of the active machine to %s", group_name) global_stack = self._application.getGlobalContainerStack() if global_stack: diff --git a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py index 79d360cee2..fb2c6e9f35 100644 --- a/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/src/UM3OutputDevicePlugin.py @@ -280,7 +280,7 @@ class UM3OutputDevicePlugin(OutputDevicePlugin): # ensure that the connection states are refreshed. self.refreshConnections() - def _checkManualDevice(self, address: str): + def _checkManualDevice(self, address: str) -> Optional[QNetworkReply]: # Check if a UM3 family device exists at this address. # If a printer responds, it will replace the preliminary printer created above # origin=manual is for tracking back the origin of the call From 57748137042656147b83ddf2097b52474c0c5863 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 15 May 2019 10:09:50 +0200 Subject: [PATCH 15/19] Use class properties Contributes to CL-1331 --- .../UM3NetworkPrinting/resources/qml/DiscoverUM3Action.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/UM3NetworkPrinting/resources/qml/DiscoverUM3Action.qml b/plugins/UM3NetworkPrinting/resources/qml/DiscoverUM3Action.qml index c250c1feb4..f65f2526dd 100644 --- a/plugins/UM3NetworkPrinting/resources/qml/DiscoverUM3Action.qml +++ b/plugins/UM3NetworkPrinting/resources/qml/DiscoverUM3Action.qml @@ -27,7 +27,7 @@ Cura.MachineAction { var printerKey = base.selectedDevice.key var printerName = base.selectedDevice.name // TODO To change when the groups have a name - if (Cura.API.machines.getCurrentMachine()["um_network_key"] != printerKey) + if (Cura.API.machines.getCurrentMachine().um_network_key != printerKey) // TODO: change to hostname { // Check if there is another instance with the same key if (!manager.existsKey(printerKey)) @@ -157,7 +157,7 @@ Cura.MachineAction var selectedKey = manager.getLastManualEntryKey() // If there is no last manual entry key, then we select the stored key (if any) if (selectedKey == "") - selectedKey = Cura.API.machines.getCurrentMachine()["um_network_key"] + selectedKey = Cura.API.machines.getCurrentMachine().um_network_key // TODO: change to host name for(var i = 0; i < model.length; i++) { if(model[i].key == selectedKey) { From 02cb41e00735ac8feb0ab8d1931d5172b9c1146d Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 15 May 2019 10:31:00 +0200 Subject: [PATCH 16/19] Improve typings Contributes to CL-1331 --- cura/API/Machines.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/API/Machines.py b/cura/API/Machines.py index 4a5761cd9b..814193c835 100644 --- a/cura/API/Machines.py +++ b/cura/API/Machines.py @@ -7,7 +7,7 @@ from UM.i18n import i18nCatalog from UM.Logger import Logger if TYPE_CHECKING: from cura.CuraApplication import CuraApplication - from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice + from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice, ConnectionType i18n_catalog = i18nCatalog("cura") From 59eb9bbab197a1dc396ae012102864637bdcdc88 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 15 May 2019 10:47:25 +0200 Subject: [PATCH 17/19] Make connection types list ints Contributes to CL-1331 --- cura/API/Machines.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/API/Machines.py b/cura/API/Machines.py index 814193c835..79b1402aae 100644 --- a/cura/API/Machines.py +++ b/cura/API/Machines.py @@ -7,7 +7,7 @@ from UM.i18n import i18nCatalog from UM.Logger import Logger if TYPE_CHECKING: from cura.CuraApplication import CuraApplication - from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice, ConnectionType + from cura.PrinterOutput.PrinterOutputDevice import PrinterOutputDevice i18n_catalog = i18nCatalog("cura") @@ -29,7 +29,7 @@ class Machine(): self.group_name = "" # type: str self.um_network_key = "" # type: str self.configuration = {} # type: Dict[str, any] - self.connection_types = [] # type: List["ConnectionType"] + self.connection_types = [] # type: List[int] class Machines(QObject): From 20e4142667218a0077e2e26dbf64865372124049 Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 15 May 2019 10:51:18 +0200 Subject: [PATCH 18/19] Final typing fix Contributes to CL-1331 --- cura/API/Machines.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/API/Machines.py b/cura/API/Machines.py index 79b1402aae..a9588c1844 100644 --- a/cura/API/Machines.py +++ b/cura/API/Machines.py @@ -28,7 +28,7 @@ class Machine(): self.group_id = "" # type: str self.group_name = "" # type: str self.um_network_key = "" # type: str - self.configuration = {} # type: Dict[str, any] + self.configuration = {} # type: Dict[str, Any] self.connection_types = [] # type: List[int] class Machines(QObject): From 51d298cca591800096f8b637b5b6a357ae56c58a Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Wed, 15 May 2019 10:58:56 +0200 Subject: [PATCH 19/19] Update Machines.py Contributes to CL-1331 --- cura/API/Machines.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/API/Machines.py b/cura/API/Machines.py index a9588c1844..de9f378d79 100644 --- a/cura/API/Machines.py +++ b/cura/API/Machines.py @@ -1,7 +1,7 @@ # Copyright (c) 2019 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. -from typing import Optional, Dict, List, TYPE_CHECKING +from typing import Optional, Dict, List, TYPE_CHECKING, Any from PyQt5.QtCore import QObject, pyqtSignal, pyqtSlot, pyqtProperty from UM.i18n import i18nCatalog from UM.Logger import Logger