Print networks more prettier and easier to read
[connman] / test / list-networks
index 94e111c..b446210 100755 (executable)
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import dbus
+import string
 
 bus = dbus.SystemBus()
 
@@ -9,12 +10,24 @@ manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
 
 properties = manager.GetProperties()
 
+def convert_ssid(ssid_list):
+       ssid = ""
+       for byte in ssid_list:
+               if (str(byte) in string.printable):
+                       ssid = ssid + str(byte)
+               else:
+                       ssid = ssid + "."
+       return ssid
+
 for path in properties["Devices"]:
        device = dbus.Interface(bus.get_object("org.moblin.connman", path),
                                                "org.moblin.connman.Device")
 
        properties = device.GetProperties()
 
+       if (properties["Type"] != "wifi" and properties["Type"] != "wimax"):
+               continue;
+
        print "[ %s ]" % (path)
 
        for path in properties["Networks"]:
@@ -26,6 +39,12 @@ for path in properties["Devices"]:
                print "    [ %s ]" % (path)
 
                for key in properties.keys():
-                       print "        %s = %s" % (key, properties[key])
+                       if (key == "WiFi.SSID"):
+                               ssid = convert_ssid(properties[key])
+                               print "        %s = [ %s ]" % (key, ssid)
+                       elif (key == "Strength"):
+                               print "        %s = %d" % (key, properties[key])
+                       else:
+                               print "        %s = %s" % (key, properties[key])
 
        print