c99b54ba0b1070355442b50c18673ecaf9490cc5
[connman] / test / test-manager
1 #!/usr/bin/python
2
3 import dbus
4
5 bus = dbus.SystemBus()
6
7 manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
8                                         "org.moblin.connman.Manager")
9
10 properties = manager.GetProperties()
11
12 def print_properties(key, value):
13         if (key == "Profiles"):
14                 interface = "org.moblin.connman.Profile"
15         elif (key == "Devices"):
16                 interface = "org.moblin.connman.Device"
17         elif (key == "Connections"):
18                 interface = "org.moblin.connman.Connection"
19         else:
20                 return
21
22         print "%s" % (key)
23         for path in value:
24                 print "    %s" % (path)
25                 obj = dbus.Interface(bus.get_object("org.moblin.connman", path),
26                                                                 interface)
27
28                 properties = obj.GetProperties()
29
30                 for key in properties.keys():
31                         if (key == "Networks"):
32                                 continue
33
34                         if (key == "Strength"):
35                                 val = int(properties[key])
36                         else:
37                                 val = str(properties[key])
38
39                         print "        %s = %s" % (key, val)
40
41                 if "Networks" in properties.keys():
42                         list = ""
43                         for path in properties["Networks"]:
44                                 val = str(path)
45                                 list = list + val[val.rfind("/") + 1:] + " "
46                         print "        Networks = [ %s]" % (list)
47
48 for key in properties.keys():
49         if key in ["Profiles", "Devices", "Connections"]:
50                 print_properties(key, properties[key])
51         else:
52                 print "%s" % (key)
53                 print "    %s" % (properties[key])