From 72523df3af05d5b89620e1679fecb43908d75ce1 Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Fri, 9 Feb 2018 11:24:11 +0100 Subject: [PATCH] ble: make sure the length of the manufacturer data is at least 1 We never encounter the issue, but I bet we will --- tuhi/ble.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tuhi/ble.py b/tuhi/ble.py index 26e81f7..55c643c 100755 --- a/tuhi/ble.py +++ b/tuhi/ble.py @@ -136,8 +136,15 @@ class BlueZDevice(GObject.Object): @GObject.Property def vendor_id(self): md = self.interface.get_cached_property('ManufacturerData') - if md is not None: - return md.keys()[0] + if md is None: + return None + + try: + return next(iter(dict(md))) + except StopIteration: + # dict is empty + pass + return None @GObject.Property