Use empty string as fallback value

This commit is contained in:
ChrisTerBeke 2019-10-01 19:53:40 +02:00
parent 76536fe715
commit 445743ab75
No known key found for this signature in database
GPG key ID: A49F1AB9D7E0C263

View file

@ -124,11 +124,11 @@ class CloudOutputDevice(UltimakerNetworkedPrinterOutputDevice):
def matchesNetworkKey(self, network_key: str) -> bool: def matchesNetworkKey(self, network_key: str) -> bool:
# Typically, a network key looks like "ultimakersystem-aabbccdd0011._ultimaker._tcp.local." # Typically, a network key looks like "ultimakersystem-aabbccdd0011._ultimaker._tcp.local."
# the host name should then be "ultimakersystem-aabbccdd0011" # the host name should then be "ultimakersystem-aabbccdd0011"
if network_key.startswith(str(self.clusterData.host_name)): if network_key.startswith(str(self.clusterData.host_name or "")):
return True return True
# However, for manually added printers, the local IP address is used in lieu of a proper # However, for manually added printers, the local IP address is used in lieu of a proper
# network key, so check for that as well. It is in the format "manual:10.1.10.1". # network key, so check for that as well. It is in the format "manual:10.1.10.1".
if network_key.endswith(str(self.clusterData.host_internal_ip)): if network_key.endswith(str(self.clusterData.host_internal_ip or "")):
return True return True
return False return False