Home | History | Annotate | Download | only in test-scripts
      1 #!/usr/bin/python
      2 
      3 import dbus, flimflam
      4 
      5 flim = flimflam.FlimFlam(dbus.SystemBus())
      6 
      7 strength = {}
      8 
      9 for device in flim.GetObjectList("Device"):
     10     device_properties = device.GetProperties(utf8_strings = True)
     11     try:
     12         if device_properties["Type"] not in ["wifi", "wimax",
     13             "bluetooth", "cellular"]:
     14             continue
     15     except Exception, e:
     16         continue
     17 
     18     for network in flim.GetObjectList("Network", device_properties):
     19         network_properties = network.GetProperties(utf8_strings = True)
     20 
     21         if "Name" not in network_properties:
     22             continue
     23         name = network_properties["Name"]
     24 
     25         if "Strength" not in network_properties:
     26             print "No strength for network %s" % name
     27             continue
     28 
     29         if strength.get(name, -1) < network_properties["Strength"]:
     30             strength[name] = network_properties["Strength"]
     31 
     32 #        print "%-14s: strength %d network %d" % \
     33 #            (name,
     34 #             int(strength.get(name, -1)),
     35 #             int(network_properties.get("Strength", -1)))
     36 
     37 for service in flim.GetObjectList("Service"):
     38     properties = service.GetProperties(utf8_strings = True)
     39     if "Name" not in properties:
     40         continue
     41 
     42     name = properties["Name"]
     43 
     44     print "%-14s: network %d service %d" % \
     45         (name, int(strength.get(name, -1)), int(properties.get("Strength", -1)))
     46