2013-03-20 20:18:24

by Joao Paulo Rechi Vita

[permalink] [raw]
Subject: [PATCH BlueZ] test: Fix list-devices when there is more than one adapter

---
test/list-devices | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/test/list-devices b/test/list-devices
index 0aac217..790b358 100755
--- a/test/list-devices
+++ b/test/list-devices
@@ -31,9 +31,6 @@ def extract_uuids(uuid_list):

objects = manager.GetManagedObjects()

-all_devices = (str(path) for path, interfaces in objects.iteritems() if
- "org.bluez.Device1" in interfaces.keys())
-
for path, interfaces in objects.iteritems():
if "org.bluez.Adapter1" not in interfaces.keys():
continue
@@ -49,6 +46,8 @@ for path, interfaces in objects.iteritems():
else:
print(" %s = %s" % (key, value))

+ all_devices = (str(path) for path, interfaces in objects.iteritems() if
+ "org.bluez.Device1" in interfaces.keys())
device_list = [d for d in all_devices if d.startswith(path + "/")]

for dev_path in device_list:
--
1.7.11.7



2013-03-25 09:36:36

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH BlueZ] test: Fix list-devices when there is more than one adapter

Hi Jo?o Paulo,

On Wed, Mar 20, 2013, Jo?o Paulo Rechi Vita wrote:
> ---
> test/list-devices | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/test/list-devices b/test/list-devices
> index 0aac217..790b358 100755
> --- a/test/list-devices
> +++ b/test/list-devices
> @@ -31,9 +31,6 @@ def extract_uuids(uuid_list):
>
> objects = manager.GetManagedObjects()
>
> -all_devices = (str(path) for path, interfaces in objects.iteritems() if
> - "org.bluez.Device1" in interfaces.keys())
> -
> for path, interfaces in objects.iteritems():
> if "org.bluez.Adapter1" not in interfaces.keys():
> continue
> @@ -49,6 +46,8 @@ for path, interfaces in objects.iteritems():
> else:
> print(" %s = %s" % (key, value))
>
> + all_devices = (str(path) for path, interfaces in objects.iteritems() if
> + "org.bluez.Device1" in interfaces.keys())
> device_list = [d for d in all_devices if d.startswith(path + "/")]
>
> for dev_path in device_list:

Your commit message should explain why the old code is wrong and how/why
your patch makes it right. In general the code above looks suspicious
since it's relying on a certain format for the object path (the adapter
path being a prefix to the device path) instead of properly looking for
devices whose "Adapter" property on the Device1 interface matches the
path of the adapter that's currently being processed.

Johan