dbus: Fix example get-list-of-interfaces operation
This commit is contained in:
parent
70993cd8e2
commit
e7f7d231a4
1 changed files with 12 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue