]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
dbus: Fix example get-list-of-interfaces operation
authorJouni Malinen <j@w1.fi>
Fri, 1 Jan 2010 11:16:33 +0000 (13:16 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 1 Jan 2010 11:16:33 +0000 (13:16 +0200)
wpa_supplicant/examples/wpas-dbus-new.py

index 934243bb9aea76a7357b36be43da29f925d5156b..156b4fb0397d5fbd9d3c6f4826b92d79dba7cb1c 100755 (executable)
@@ -25,9 +25,13 @@ def byte_array_to_string(s):
        return r
 
 def list_interfaces(wpas_obj):
-       ifaces = wpas_obj.Interfaces
-       for i in ifaces:
-               print "%s" (i)
+       ifaces = wpas_obj.Get(WPAS_DBUS_INTERFACE, 'Interfaces',
+                             dbus_interface=dbus.PROPERTIES_IFACE)
+       for path in ifaces:
+               if_obj = bus.get_object(WPAS_DBUS_SERVICE, path)
+               ifname = if_obj.Get(WPAS_DBUS_INTERFACES_INTERFACE, 'Ifname',
+                             dbus_interface=dbus.PROPERTIES_IFACE)
+               print ifname
 
 def stateChanged(newState, oldState):
        print "StateChanged(%s -> %s)" % (oldState, newState)
@@ -91,6 +95,11 @@ def main():
        global bus
        bus = dbus.SystemBus()
        wpas_obj = bus.get_object(WPAS_DBUS_SERVICE, WPAS_DBUS_OPATH)
+
+       if len(sys.argv) != 2:
+               list_interfaces(wpas_obj)
+               os._exit(1)
+
        wpas = dbus.Interface(wpas_obj, WPAS_DBUS_INTERFACE)
        bus.add_signal_receiver(scanDone,
                                dbus_interface=WPAS_DBUS_INTERFACES_INTERFACE,
@@ -105,10 +114,6 @@ def main():
                                dbus_interface=WPAS_DBUS_INTERFACES_INTERFACE,
                                signal_name="StateChanged")
 
-       if len(sys.argv) != 2:
-               list_interfaces(wpas_obj)
-               os._exit(1)
-
        ifname = sys.argv[1]
 
        # See if wpa_supplicant already knows about this interface