xref: /freebsd/contrib/wpa/wpa_supplicant/examples/wpas-dbus-new-getall.py (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1#!/usr/bin/python
2
3import dbus
4import sys, os
5import time
6import gobject
7
8def main():
9	bus = dbus.SystemBus()
10	wpas_obj = bus.get_object("fi.w1.wpa_supplicant1",
11				  "/fi/w1/wpa_supplicant1")
12	props = wpas_obj.GetAll("fi.w1.wpa_supplicant1",
13				dbus_interface=dbus.PROPERTIES_IFACE)
14	print("GetAll(fi.w1.wpa_supplicant1, /fi/w1/wpa_supplicant1):")
15	print(props)
16
17	if len(sys.argv) != 2:
18		os._exit(1)
19
20	ifname = sys.argv[1]
21
22	wpas = dbus.Interface(wpas_obj, "fi.w1.wpa_supplicant1")
23	path = wpas.GetInterface(ifname)
24	if_obj = bus.get_object("fi.w1.wpa_supplicant1", path)
25	props = if_obj.GetAll("fi.w1.wpa_supplicant1.Interface",
26			      dbus_interface=dbus.PROPERTIES_IFACE)
27	print('')
28	print("GetAll(fi.w1.wpa_supplicant1.Interface, %s):" % (path))
29	print(props)
30
31	props = if_obj.GetAll("fi.w1.wpa_supplicant1.Interface.WPS",
32			      dbus_interface=dbus.PROPERTIES_IFACE)
33	print('')
34	print("GetAll(fi.w1.wpa_supplicant1.Interface.WPS, %s):" % (path))
35	print(props)
36
37	res = if_obj.Get("fi.w1.wpa_supplicant1.Interface", 'BSSs',
38			 dbus_interface=dbus.PROPERTIES_IFACE)
39	if len(res) > 0:
40		bss_obj = bus.get_object("fi.w1.wpa_supplicant1", res[0])
41		props = bss_obj.GetAll("fi.w1.wpa_supplicant1.BSS",
42				       dbus_interface=dbus.PROPERTIES_IFACE)
43		print('')
44		print("GetAll(fi.w1.wpa_supplicant1.BSS, %s):" % (res[0]))
45		print(props)
46
47	res = if_obj.Get("fi.w1.wpa_supplicant1.Interface", 'Networks',
48			 dbus_interface=dbus.PROPERTIES_IFACE)
49	if len(res) > 0:
50		net_obj = bus.get_object("fi.w1.wpa_supplicant1", res[0])
51		props = net_obj.GetAll("fi.w1.wpa_supplicant1.Network",
52				       dbus_interface=dbus.PROPERTIES_IFACE)
53		print('')
54		print("GetAll(fi.w1.wpa_supplicant1.Network, %s):" % (res[0]))
55		print(props)
56
57if __name__ == "__main__":
58	main()
59