From: Samuel Ortiz Date: Tue, 16 Feb 2010 10:52:11 +0000 (+0100) Subject: Update all test scripts using devices properties directly X-Git-Tag: 0.50~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9479134d6444c9e9da98ad5bb5ba4891a86d51b;p=platform%2Fupstream%2Fconnman.git Update all test scripts using devices properties directly We need to go through the technology list first in order to access the devices properties. --- diff --git a/test/disable-device b/test/disable-device index caa954f..acf962b 100755 --- a/test/disable-device +++ b/test/disable-device @@ -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)); diff --git a/test/enable-device b/test/enable-device index 6451441..e6f9518 100755 --- a/test/enable-device +++ b/test/enable-device @@ -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)); diff --git a/test/set-passphrase b/test/set-passphrase index a104416..acce350 100755 --- a/test/set-passphrase +++ b/test/set-passphrase @@ -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]) diff --git a/test/show-introspection b/test/show-introspection index bbf93c8..5e392c7 100755 --- a/test/show-introspection +++ b/test/show-introspection @@ -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() diff --git a/test/test-connman b/test/test-connman index 3845508..aa781c3 100755 --- a/test/test-connman +++ b/test/test-connman @@ -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"