mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-09 01:19:00 +08:00
Fix type checking for DiscoverUM3Action
This commit is contained in:
parent
80d2a78463
commit
d2746d03c1
@ -124,25 +124,31 @@ class DiscoverUM3Action(MachineAction):
|
|||||||
@pyqtSlot(QObject)
|
@pyqtSlot(QObject)
|
||||||
def associateActiveMachineWithPrinterDevice(self, printer_device: Optional["PrinterOutputDevice"]) -> None:
|
def associateActiveMachineWithPrinterDevice(self, printer_device: Optional["PrinterOutputDevice"]) -> None:
|
||||||
Logger.log("d", "Attempting to set the network key of the active machine to %s", printer_device.key)
|
Logger.log("d", "Attempting to set the network key of the active machine to %s", printer_device.key)
|
||||||
global_container_stack = CuraApplication.getInstance().getGlobalContainerStack()
|
if not printer_device:
|
||||||
if global_container_stack:
|
return
|
||||||
meta_data = global_container_stack.getMetaData()
|
|
||||||
if "um_network_key" in meta_data:
|
|
||||||
previous_network_key= meta_data["um_network_key"]
|
|
||||||
global_container_stack.setMetaDataEntry("um_network_key", printer_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), printer_device.key)
|
|
||||||
global_container_stack.removeMetaDataEntry("network_authentication_id")
|
|
||||||
global_container_stack.removeMetaDataEntry("network_authentication_key")
|
|
||||||
CuraApplication.getInstance().getMachineManager().replaceContainersMetadata(key = "um_network_key", value = previous_network_key, new_value = printer_device.key)
|
|
||||||
|
|
||||||
if "connection_type" in meta_data:
|
global_container_stack = CuraApplication.getInstance().getGlobalContainerStack()
|
||||||
previous_connection_type = meta_data["connection_type"]
|
if not global_container_stack:
|
||||||
global_container_stack.setMetaDataEntry("connection_type", printer_device.connectionType.value)
|
return
|
||||||
CuraApplication.getInstance().getMachineManager().replaceContainersMetadata(key = "connection_type", value = previous_connection_type, new_value = printer_device.connectionType.value)
|
|
||||||
else:
|
meta_data = global_container_stack.getMetaData()
|
||||||
global_container_stack.setMetaDataEntry("um_network_key", printer_device.key)
|
if "um_network_key" in meta_data:
|
||||||
|
previous_network_key = meta_data["um_network_key"]
|
||||||
|
global_container_stack.setMetaDataEntry("um_network_key", printer_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), printer_device.key)
|
||||||
|
global_container_stack.removeMetaDataEntry("network_authentication_id")
|
||||||
|
global_container_stack.removeMetaDataEntry("network_authentication_key")
|
||||||
|
CuraApplication.getInstance().getMachineManager().replaceContainersMetadata(key = "um_network_key", value = previous_network_key, new_value = printer_device.key)
|
||||||
|
|
||||||
|
if "connection_type" in meta_data:
|
||||||
|
previous_connection_type = meta_data["connection_type"]
|
||||||
global_container_stack.setMetaDataEntry("connection_type", printer_device.connectionType.value)
|
global_container_stack.setMetaDataEntry("connection_type", printer_device.connectionType.value)
|
||||||
|
CuraApplication.getInstance().getMachineManager().replaceContainersMetadata(key = "connection_type", value = previous_connection_type, new_value = printer_device.connectionType.value)
|
||||||
|
else:
|
||||||
|
global_container_stack.setMetaDataEntry("um_network_key", printer_device.key)
|
||||||
|
global_container_stack.setMetaDataEntry("connection_type", printer_device.connectionType.value)
|
||||||
|
|
||||||
if self._network_plugin:
|
if self._network_plugin:
|
||||||
# Ensure that the connection states are refreshed.
|
# Ensure that the connection states are refreshed.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user