From a52c62f6bb3b82b51cb5f54a66a12af38899e82a Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Wed, 16 Nov 2016 21:45:25 +0100 Subject: [PATCH 1/3] Adding debug message when type != 'printer' Just for the case we lose a device at this point. --- NetworkPrinterOutputDevicePlugin.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NetworkPrinterOutputDevicePlugin.py b/NetworkPrinterOutputDevicePlugin.py index bb1fade0bc..666c398382 100644 --- a/NetworkPrinterOutputDevicePlugin.py +++ b/NetworkPrinterOutputDevicePlugin.py @@ -194,6 +194,8 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin): if info.properties.get(b"type", None) == b'printer': address = '.'.join(map(lambda n: str(n), info.address)) self.addPrinterSignal.emit(str(name), address, info.properties) + else: + Logger.log("w", "The type of the found device is '%s', not 'printer'! Ignoring.." % name) else: Logger.log("w", "Could not get information about %s" % name) From 0f6c7a94058473e8880e96b397d273f4d282cca5 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Wed, 16 Nov 2016 21:50:11 +0100 Subject: [PATCH 2/3] Correcting warning .. also decoding the type of device and using it for the if clause, too. --- NetworkPrinterOutputDevicePlugin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/NetworkPrinterOutputDevicePlugin.py b/NetworkPrinterOutputDevicePlugin.py index 666c398382..e69b700a6c 100644 --- a/NetworkPrinterOutputDevicePlugin.py +++ b/NetworkPrinterOutputDevicePlugin.py @@ -191,11 +191,12 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin): info = zeroconf.get_service_info(service_type, name) if info: - if info.properties.get(b"type", None) == b'printer': + typeOfDevice = info.properties.get(b"type", None).decode("utf-8") + if typeOfDevice == "printer": address = '.'.join(map(lambda n: str(n), info.address)) self.addPrinterSignal.emit(str(name), address, info.properties) else: - Logger.log("w", "The type of the found device is '%s', not 'printer'! Ignoring.." % name) + Logger.log("w", "The type of the found device is '%s', not 'printer'! Ignoring.." %typeOfDevice ) else: Logger.log("w", "Could not get information about %s" % name) From 808417b152f1c1c69801bc78242f0a8b3b5ae404 Mon Sep 17 00:00:00 2001 From: Thomas Karl Pietrowski Date: Thu, 17 Nov 2016 10:28:35 +0100 Subject: [PATCH 3/3] Renaming typeOfDevice -> type_of_device --- NetworkPrinterOutputDevicePlugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NetworkPrinterOutputDevicePlugin.py b/NetworkPrinterOutputDevicePlugin.py index e69b700a6c..7a86002210 100644 --- a/NetworkPrinterOutputDevicePlugin.py +++ b/NetworkPrinterOutputDevicePlugin.py @@ -191,12 +191,12 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin): info = zeroconf.get_service_info(service_type, name) if info: - typeOfDevice = info.properties.get(b"type", None).decode("utf-8") - if typeOfDevice == "printer": + type_of_device = info.properties.get(b"type", None).decode("utf-8") + if type_of_device == "printer": address = '.'.join(map(lambda n: str(n), info.address)) self.addPrinterSignal.emit(str(name), address, info.properties) else: - Logger.log("w", "The type of the found device is '%s', not 'printer'! Ignoring.." %typeOfDevice ) + Logger.log("w", "The type of the found device is '%s', not 'printer'! Ignoring.." %type_of_device ) else: Logger.log("w", "Could not get information about %s" % name)