Print signal strength as integer and not character
[connman] / test / list-networks
1 #!/usr/bin/python
2
3 import dbus
4 import string
5
6 bus = dbus.SystemBus()
7
8 manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
9                                         "org.moblin.connman.Manager")
10
11 properties = manager.GetProperties()
12
13 def convert_ssid(ssid_list):
14         ssid = ""
15         for byte in ssid_list:
16                 if (str(byte) in string.printable):
17                         ssid = ssid + str(byte)
18                 else:
19                         ssid = ssid + "."
20         return ssid
21
22 for path in properties["Devices"]:
23         device = dbus.Interface(bus.get_object("org.moblin.connman", path),
24                                                 "org.moblin.connman.Device")
25
26         properties = device.GetProperties()
27
28         if (properties["Type"] != "wifi" and properties["Type"] != "wimax"):
29                 continue;
30
31         print "[ %s ]" % (path)
32
33         for path in properties["Networks"]:
34                 network = dbus.Interface(bus.get_object("org.moblin.connman", path),
35                                                 "org.moblin.connman.Network")
36
37                 properties = network.GetProperties()
38
39                 print "    [ %s ]" % (path)
40
41                 for key in properties.keys():
42                         if (key == "WiFi.SSID"):
43                                 ssid = convert_ssid(properties[key])
44                                 print "        %s = [ %s ]" % (key, ssid)
45                         elif (key == "Strength"):
46                                 print "        %s = %d" % (key, properties[key])
47                         else:
48                                 print "        %s = %s" % (key, properties[key])
49
50         print