Thread (18 messages) flat view 18 messages, 2 authors, 2012-11-16

[RFC v1 15/16] test: Use ObjectManager instead of Devices property

From: Mikel Astiz <hidden>
Date: 2012-11-15 15:09:18
Subsystem: the rest · Maintainer: Linus Torvalds

From: Mikel Astiz <redacted>

Use the objects and interfaces reported by the ObjectManager in order
to list the available devices per adapter.
---
 test/list-devices | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/test/list-devices b/test/list-devices
index fcff3e7..e8f3f24 100755
--- a/test/list-devices
+++ b/test/list-devices
@@ -30,6 +30,10 @@ def extract_uuids(uuid_list):
 	return list
 
 objects = manager.GetManagedObjects()
+
+all_devices = (str(path) for path, interfaces in objects.iteritems() if
+					"org.bluez.Device" in interfaces.keys())
+
 for path, interfaces in objects.iteritems():
 	if "org.bluez.Adapter" not in interfaces.keys():
 		continue
@@ -39,19 +43,13 @@ for path, interfaces in objects.iteritems():
 	properties = interfaces["org.bluez.Adapter"]
 	for key in properties.keys():
 		value = properties[key]
-		if (key == "Devices"):
-			list = extract_objects(value)
-			print("    %s = %s" % (key, list))
-		elif (key == "UUIDs"):
+		if (key == "UUIDs"):
 			list = extract_uuids(value)
 			print("    %s = %s" % (key, list))
 		else:
 			print("    %s = %s" % (key, value))
 
-	try:
-		device_list = properties["Devices"]
-	except:
-		device_list = []
+	device_list = [d for d in all_devices if d.startswith(path + "/")]
 
 	for dev_path in device_list:
 		print("    [ " + dev_path + " ]")
-- 
1.7.11.7
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help