summaryrefslogtreecommitdiff
path: root/test/list-adapters
blob: c8e7dc6fea21a6f02ace3f4d5d0951084c969d0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python

import dbus


def extract_list(list):
	val = "["
	for i in list:
		val += " " + str(i)
	val += " ]"
	return val

bus = dbus.SessionBus()

manager = dbus.Interface(bus.get_object("org.neard", "/"),
					"org.neard.Manager")


properties = manager.GetProperties()

for path in properties["Adapters"]:
    print "[ %s ]" % (path)

    adapter = dbus.Interface(bus.get_object("org.neard", path),
						"org.neard.Adapter")

    properties = adapter.GetProperties()

    for key in properties.keys():
        if key in ["Powered", "Polling"]:
            if properties[key] == dbus.Boolean(1):
                val = "true"
            else:
                val = "false"
        elif key in ["Protocols", "Targets"]:
            val = extract_list(properties[key])
        else:
            val = str(properties[key])
            
        print "        %s = %s" % (key, val)