Update all test scripts using devices properties directly
authorSamuel Ortiz <sameo@linux.intel.com>
Tue, 16 Feb 2010 10:52:11 +0000 (11:52 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 16 Feb 2010 15:43:23 +0000 (07:43 -0800)
We need to go through the technology list first in order to access the
devices properties.

test/disable-device
test/enable-device
test/set-passphrase
test/show-introspection
test/test-connman

index caa954f..acf962b 100755 (executable)
@@ -14,18 +14,24 @@ manager = dbus.Interface(bus.get_object('org.moblin.connman', "/"),
 
 properties = manager.GetProperties()
 
-for path in properties["Devices"]:
-       device = dbus.Interface(bus.get_object('org.moblin.connman', path),
-                                               'org.moblin.connman.Device')
+for path in properties["Technologies"]:
+       technology = dbus.Interface(bus.get_object("org.moblin.connman", path),
+                                               "org.moblin.connman.Technology")
 
-       properties = device.GetProperties()
+       properties = technology.GetProperties()
 
-       if "Interface" not in properties.keys():
-               continue
+       for path in properties["Devices"]:
+               device = dbus.Interface(bus.get_object('org.moblin.connman', path),
+                                                       'org.moblin.connman.Device')
 
-       if properties["Interface"] != sys.argv[1]:
-               continue
+               properties = device.GetProperties()
 
-       print "Disabling device %s" % (path)
+               if "Interface" not in properties.keys():
+                       continue
 
-       device.SetProperty("Powered", dbus.Boolean(0));
+               if properties["Interface"] != sys.argv[1]:
+                       continue
+
+               print "Disabling device %s" % (path)
+
+               device.SetProperty("Powered", dbus.Boolean(0));
index 6451441..e6f9518 100755 (executable)
@@ -14,18 +14,24 @@ manager = dbus.Interface(bus.get_object('org.moblin.connman', "/"),
 
 properties = manager.GetProperties()
 
-for path in properties["Devices"]:
-       device = dbus.Interface(bus.get_object('org.moblin.connman', path),
-                                               'org.moblin.connman.Device')
+for path in properties["Technologies"]:
+       technology = dbus.Interface(bus.get_object("org.moblin.connman", path),
+                                               "org.moblin.connman.Technology")
 
-       properties = device.GetProperties()
+       properties = technology.GetProperties()
 
-       if "Interface" not in properties.keys():
-               continue
+       for path in properties["Devices"]:
+               device = dbus.Interface(bus.get_object('org.moblin.connman', path),
+                                                       'org.moblin.connman.Device')
 
-       if properties["Interface"] != sys.argv[1]:
-               continue
+               properties = device.GetProperties()
 
-       print "Enabling device %s" % (path)
+               if "Interface" not in properties.keys():
+                       continue
 
-       device.SetProperty("Powered", dbus.Boolean(1));
+               if properties["Interface"] != sys.argv[1]:
+                       continue
+
+               print "Enabling device %s" % (path)
+
+               device.SetProperty("Powered", dbus.Boolean(1));
index a104416..acce350 100755 (executable)
@@ -14,24 +14,30 @@ manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
 
 properties = manager.GetProperties()
 
-for path in properties["Devices"]:
-       device = dbus.Interface(bus.get_object("org.moblin.connman", path),
-                                               "org.moblin.connman.Device")
+for path in properties["Technologies"]:
+       technology = dbus.Interface(bus.get_object("org.moblin.connman", path),
+                                               "org.moblin.connman.Technology")
 
-       properties = device.GetProperties()
+       properties = technology.GetProperties()
 
-       if (properties["Type"] != "wifi" and properties["Type"] != "wimax"):
-               continue;
+       for path in properties["Devices"]:
+               device = dbus.Interface(bus.get_object("org.moblin.connman", path),
+                                                       "org.moblin.connman.Device")
 
-       for path in properties["Networks"]:
-               network = dbus.Interface(bus.get_object("org.moblin.connman", path),
-                                               "org.moblin.connman.Network")
+               properties = device.GetProperties()
 
-               properties = network.GetProperties()
+               if (properties["Type"] != "wifi" and properties["Type"] != "wimax"):
+                       continue;
 
-               if "Name" not in properties:
-                       continue
+               for path in properties["Networks"]:
+                       network = dbus.Interface(bus.get_object("org.moblin.connman", path),
+                                                       "org.moblin.connman.Network")
 
-               if properties["Name"] == sys.argv[1]:
-                       print "Setting passphrase for %s" % (path)
-                       network.SetProperty("WiFi.Passphrase", sys.argv[2])
+                       properties = network.GetProperties()
+
+                       if "Name" not in properties:
+                               continue
+
+                       if properties["Name"] == sys.argv[1]:
+                               print "Setting passphrase for %s" % (path)
+                               network.SetProperty("WiFi.Passphrase", sys.argv[2])
index bbf93c8..5e392c7 100755 (executable)
@@ -14,8 +14,14 @@ manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
 
 properties = manager.GetProperties()
 
-for path in properties["Devices"]:
-       object = dbus.Interface(bus.get_object("org.moblin.connman", path),
-                                       "org.freedesktop.DBus.Introspectable")
+for path in properties["Technologies"]:
+       technology = dbus.Interface(bus.get_object("org.moblin.connman", path),
+                                               "org.moblin.connman.Technology")
 
-       print object.Introspect()
+       properties = technology.GetProperties()
+
+       for path in properties["Devices"]:
+               object = dbus.Interface(bus.get_object("org.moblin.connman", path),
+                                               "org.freedesktop.DBus.Introspectable")
+
+               print object.Introspect()
index 3845508..aa781c3 100755 (executable)
@@ -149,6 +149,72 @@ def print_services(services):
 
                print "%s %-26s { %s }" % (favorite, name, identifier)
 
+def device_handle(devices, interface):
+       for path in devices:
+               device = dbus.Interface(bus.get_object("org.moblin.connman", path),
+                                               "org.moblin.connman.Device")
+
+               properties = device.GetProperties()
+
+               if "Interface" not in properties.keys():
+                       continue
+
+               if interface != "" and properties["Interface"] != interface:
+                       continue
+
+               if command == "scan":
+                       if properties["Type"] in ["wifi", "wimax"]:
+                               interface = properties["Interface"]
+                               print "Scan for device %s" % (interface)
+                               device.ProposeScan()
+                       else:
+                               print "No scanning for device %s" % (interface)
+               elif command == "scan_interval" and value != "":
+                       device.SetProperty("ScanInterval", dbus.UInt16(value))
+               elif command in ["networks", "net"]:
+                       if "Networks" in properties.keys():
+                               print_networks(properties["Networks"])
+                       else:
+                               print "Device has no networks"
+               elif command in ["connect", "conn"] and value != "":
+                       if "Networks" in properties.keys():
+                               select_network(properties["Networks"], value)
+                       else:
+                               print "Device can't connect networks"
+               elif command in ["connect", "conn"]:
+                       print "Need to specify network"
+               elif command in ["disconnect", "disc"] and value != "":
+                       if "Networks" in properties.keys():
+                               disconnect_network(properties["Networks"], value)
+                       else:
+                               print "Device has no networks"
+               elif command in ["discconnect", "disc"]:
+                       if "Networks" in properties.keys():
+                               disconnect_network(properties["Networks"], "")
+                       else:
+                               print "Device has no networks"
+               elif command == "powered" and value != "":
+                       if value == "on":
+                               powered = dbus.Boolean(1)
+                       elif value == "off":
+                               powered = dbus.Boolean(0)
+                       else:
+                               powered = dbus.Boolean(value)
+                       device.SetProperty("Powered", powered)
+               elif command == "powered":
+                       interface = properties["Interface"]
+                       if properties["Powered"] == dbus.Boolean(1):
+                               powered = "on"
+                       else:
+                               powered = "off"
+                       print "Device %s is powered %s" % (interface, powered)
+               elif command == "list" or command == "":
+                       print_properties(path, properties)
+               else:
+                       print "Unknown command"
+
+
+
 if sys.argv[1] == "state":
        properties = manager.GetProperties()
 
@@ -349,68 +415,13 @@ elif sys.argv[1] == "dev":
                        if len(sys.argv) > 4:
                                value = sys.argv[4]
 
-       for path in properties["Devices"]:
-               device = dbus.Interface(bus.get_object("org.moblin.connman", path),
-                                               "org.moblin.connman.Device")
-
-               properties = device.GetProperties()
-
-               if "Interface" not in properties.keys():
-                       continue
+       for path in properties["Technologies"]:
+               technology = dbus.Interface(bus.get_object("org.moblin.connman", path),
+                                                       "org.moblin.connman.Technology")
 
-               if interface != "" and properties["Interface"] != interface:
-                       continue
+               properties = technology.GetProperties()
 
-               if command == "scan":
-                       if properties["Type"] in ["wifi", "wimax"]:
-                               interface = properties["Interface"]
-                               print "Scan for device %s" % (interface)
-                               device.ProposeScan()
-                       else:
-                               print "No scanning for device %s" % (interface)
-               elif command == "scan_interval" and value != "":
-                       device.SetProperty("ScanInterval", dbus.UInt16(value))
-               elif command in ["networks", "net"]:
-                       if "Networks" in properties.keys():
-                               print_networks(properties["Networks"])
-                       else:
-                               print "Device has no networks"
-               elif command in ["connect", "conn"] and value != "":
-                       if "Networks" in properties.keys():
-                               select_network(properties["Networks"], value)
-                       else:
-                               print "Device can't connect networks"
-               elif command in ["connect", "conn"]:
-                       print "Need to specify network"
-               elif command in ["disconnect", "disc"] and value != "":
-                       if "Networks" in properties.keys():
-                               disconnect_network(properties["Networks"], value)
-                       else:
-                               print "Device has no networks"
-               elif command in ["discconnect", "disc"]:
-                       if "Networks" in properties.keys():
-                               disconnect_network(properties["Networks"], "")
-                       else:
-                               print "Device has no networks"
-               elif command == "powered" and value != "":
-                       if value == "on":
-                               powered = dbus.Boolean(1)
-                       elif value == "off":
-                               powered = dbus.Boolean(0)
-                       else:
-                               powered = dbus.Boolean(value)
-                       device.SetProperty("Powered", powered)
-               elif command == "powered":
-                       interface = properties["Interface"]
-                       if properties["Powered"] == dbus.Boolean(1):
-                               powered = "on"
-                       else:
-                               powered = "off"
-                       print "Device %s is powered %s" % (interface, powered)
-               elif command == "list" or command == "":
-                       print_properties(path, properties)
-               else:
-                       print "Unknown command"
+               device_handle(properties["Devices"], interface)
 
 else:
        print "Unknown command"