Fix refresh button functionality for network printing

This commit is contained in:
ChrisTerBeke 2019-08-09 09:24:32 +02:00
parent 5bdef34121
commit 11ef53905b
2 changed files with 11 additions and 3 deletions

View file

@ -57,10 +57,14 @@ class LocalClusterOutputDeviceManager:
## Stop network discovery and clean up discovered devices.
def stop(self) -> None:
self._zero_conf_client.stop()
# Cleanup all manual devices.
for instance_name in list(self._discovered_devices):
self._onDiscoveredDeviceRemoved(instance_name)
## Restart discovery on the local network.
def startDiscovery(self):
self.stop()
self.start()
## Add a networked printer manually by address.
def addManualDevice(self, address: str, callback: Optional[Callable[[bool, str], None]] = None) -> None:
api_client = ClusterApiClient(address, lambda error: print(error))
@ -210,12 +214,12 @@ class LocalClusterOutputDeviceManager:
if Version(device.firmwareVersion) < self.MIN_SUPPORTED_CLUSTER_VERSION:
LegacyDeviceNoLongerSupportedMessage().show()
return
# Tell the user that they cannot connect to a non-host printer.
if device.clusterSize < 1:
NotClusterHostMessage().show()
return
device.connect()
machine.addConfiguredConnectionType(device.connectionType.value)
CuraApplication.getInstance().getOutputDeviceManager().addOutputDevice(device)