diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-03-14 23:44:23 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-03-14 23:44:23 +0000 |
commit | b72732982da4e39545870715dbdc8a7750f3cdf2 (patch) | |
tree | 77ede1444fe1f932ff4afcebec159fd49c2840ea /hcid/list-devices | |
parent | ab3715031fc705620d41e2877cbab0082ba2dd71 (diff) |
Update string type handling
Diffstat (limited to 'hcid/list-devices')
-rwxr-xr-x | hcid/list-devices | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/hcid/list-devices b/hcid/list-devices index 6ee4f5aa..ec6c580a 100755 --- a/hcid/list-devices +++ b/hcid/list-devices @@ -4,50 +4,49 @@ import dbus bus = dbus.SystemBus() +manager = dbus.Interface(bus.get_object("org.bluez", "/"), + "org.bluez.Manager") def extract_uuids(uuid_list): - list = '' + list = "" for uuid in uuid_list: - if (uuid.endswith('-0000-1000-8000-00805f9b34fb')): - if (uuid.startswith('0000')): - val = '0x' + uuid[4:8] + if (uuid.endswith("-0000-1000-8000-00805f9b34fb")): + if (uuid.startswith("0000")): + val = "0x" + uuid[4:8] else: - val = '0x' + uuid[0:8] + val = "0x" + uuid[0:8] else: val = str(uuid) - list = list + val + ' ' + list = list + val + " " return list - -manager = dbus.Interface(bus.get_object('org.bluez', '/'), 'org.bluez.Manager') - adapter_list = manager.ListAdapters() for i in adapter_list: - adapter = dbus.Interface(bus.get_object('org.bluez', i), - 'org.bluez.Adapter') - print '[ ' + i + ' ]' + adapter = dbus.Interface(bus.get_object("org.bluez", i), + "org.bluez.Adapter") + print "[ " + i + " ]" properties = adapter.GetProperties() for key in properties.keys(): - print ' %s = %s' % (key, properties[key]) + print " %s = %s" % (key, properties[key]) device_list = adapter.ListDevices() for n in device_list: - device = dbus.Interface(bus.get_object('org.bluez', n), - 'org.bluez.Device') - print ' [ ' + n + ' ]' + device = dbus.Interface(bus.get_object("org.bluez", n), + "org.bluez.Device") + print " [ " + n + " ]" properties = device.GetProperties() for key in properties.keys(): value = properties[key] - if (key == 'UUID' or key == 'UUIDs'): + if (key == "UUIDs"): list = extract_uuids(value) - print ' %s = %s' % (key, list) + print " %s = %s" % (key, list) elif (key == "Class"): - print ' %s = 0x%06x' % (key, value) + print " %s = 0x%06x" % (key, value) else: - print ' %s = %s' % (key, value) + print " %s = %s" % (key, value) print |