From 4bc9e7cbd54128c9844adabdda0dcd1281c1e4d5 Mon Sep 17 00:00:00 2001 From: Isaac Hermida Date: Fri, 4 Aug 2017 08:39:35 +0200 Subject: [PATCH] bluez5: port test-discovery and bluezutils.py to work with python3 https://jira.digi.com/browse/DEL-4039 Signed-off-by: Isaac Hermida --- .../0025-port-test-discovery-to-python3.patch | 99 +++++++++++++++++++ .../bluez/bluez5_5.41.bbappend | 3 +- 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 meta-digi-dey/recipes-connectivity/bluez/bluez5-5.41/0025-port-test-discovery-to-python3.patch diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.41/0025-port-test-discovery-to-python3.patch b/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.41/0025-port-test-discovery-to-python3.patch new file mode 100644 index 000000000..25cc37ccf --- /dev/null +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5-5.41/0025-port-test-discovery-to-python3.patch @@ -0,0 +1,99 @@ +From: Isaac Hermida +Date: Thu, 3 Aug 2017 14:10:43 +0200 +Subject: [PATCH] port test-discovery to python3 + +Signed-off-by: Isaac Hermida +--- + test/bluezutils.py | 4 ++-- + test/test-discovery | 16 +++++++++------- + 2 files changed, 11 insertions(+), 9 deletions(-) + +diff --git a/test/bluezutils.py b/test/bluezutils.py +index de08cbdcb712..cd8964082450 100644 +--- a/test/bluezutils.py ++++ b/test/bluezutils.py +@@ -15,7 +15,7 @@ def find_adapter(pattern=None): + + def find_adapter_in_objects(objects, pattern=None): + bus = dbus.SystemBus() +- for path, ifaces in objects.iteritems(): ++ for path, ifaces in objects.items(): + adapter = ifaces.get(ADAPTER_INTERFACE) + if adapter is None: + continue +@@ -35,7 +35,7 @@ def find_device_in_objects(objects, device_address, adapter_pattern=None): + if adapter_pattern: + adapter = find_adapter_in_objects(objects, adapter_pattern) + path_prefix = adapter.object_path +- for path, ifaces in objects.iteritems(): ++ for path, ifaces in objects.items(): + device = ifaces.get(DEVICE_INTERFACE) + if device is None: + continue +diff --git a/test/test-discovery b/test/test-discovery +index cea77683d726..852611c862ea 100755 +--- a/test/test-discovery ++++ b/test/test-discovery +@@ -1,4 +1,4 @@ +-#!/usr/bin/python ++#!/usr/bin/python3 + + from __future__ import absolute_import, print_function, unicode_literals + +@@ -18,9 +18,9 @@ def print_compact(address, properties): + name = "" + address = "" + +- for key, value in properties.iteritems(): ++ for key, value in properties.items(): + if type(value) is dbus.String: +- value = unicode(value).encode('ascii', 'replace') ++ value = str(value) + if (key == "Name"): + name = value + elif (key == "Address"): +@@ -41,7 +41,7 @@ def print_normal(address, properties): + for key in properties.keys(): + value = properties[key] + if type(value) is dbus.String: +- value = unicode(value).encode('ascii', 'replace') ++ value = str(value) + if (key == "Class"): + print(" %s = 0x%06x" % (key, value)) + else: +@@ -61,6 +61,8 @@ def skip_dev(old_dev, new_dev): + return False + + def interfaces_added(path, interfaces): ++ if "org.bluez.Device1" not in interfaces.keys(): ++ return + properties = interfaces["org.bluez.Device1"] + if not properties: + return +@@ -70,7 +72,7 @@ def interfaces_added(path, interfaces): + + if compact and skip_dev(dev, properties): + return +- devices[path] = dict(devices[path].items() + properties.items()) ++ devices[path] = dict(list(devices[path].items()) + list(properties.items())) + else: + devices[path] = properties + +@@ -93,7 +95,7 @@ def properties_changed(interface, changed, invalidated, path): + + if compact and skip_dev(dev, changed): + return +- devices[path] = dict(devices[path].items() + changed.items()) ++ devices[path] = dict(list(devices[path].items()) + list(changed.items())) + else: + devices[path] = changed + +@@ -152,7 +154,7 @@ if __name__ == '__main__': + om = dbus.Interface(bus.get_object("org.bluez", "/"), + "org.freedesktop.DBus.ObjectManager") + objects = om.GetManagedObjects() +- for path, interfaces in objects.iteritems(): ++ for path, interfaces in objects.items(): + if "org.bluez.Device1" in interfaces: + devices[path] = interfaces["org.bluez.Device1"] + diff --git a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend index 2e7c7e210..7e54c309c 100644 --- a/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend +++ b/meta-digi-dey/recipes-connectivity/bluez/bluez5_5.41.bbappend @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Digi International. +# Copyright (C) 2015-2017 Digi International. FILESEXTRAPATHS_prepend := "${THISDIR}/${BP}:" @@ -7,6 +7,7 @@ SRC_URI += " \ file://main.conf \ file://0001-hcitool-do-not-show-unsupported-refresh-option.patch \ file://0002-hcitool-increase-the-shown-connection-limit-to-20.patch \ + file://0025-port-test-discovery-to-python3.patch \ " SRC_URI_append_ccimx6ul = " \