File: wpas-dbus-new-getall.py

package info (click to toggle)
wpa 2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 13,672 kB
  • sloc: ansic: 262,665; cpp: 4,656; python: 2,911; makefile: 2,796; sh: 1,466; php: 733; xml: 54; perl: 48
file content (59 lines) | stat: -rwxr-xr-x 1,742 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/python

import dbus
import sys, os
import time
import gobject

def main():
	bus = dbus.SystemBus()
	wpas_obj = bus.get_object("fi.w1.wpa_supplicant1",
				  "/fi/w1/wpa_supplicant1")
	props = wpas_obj.GetAll("fi.w1.wpa_supplicant1",
				dbus_interface=dbus.PROPERTIES_IFACE)
	print "GetAll(fi.w1.wpa_supplicant1, /fi/w1/wpa_supplicant1):"
	print props

	if len(sys.argv) != 2:
		os._exit(1)

	ifname = sys.argv[1]

	wpas = dbus.Interface(wpas_obj, "fi.w1.wpa_supplicant1")
	path = wpas.GetInterface(ifname)
	if_obj = bus.get_object("fi.w1.wpa_supplicant1", path)
	props = if_obj.GetAll("fi.w1.wpa_supplicant1.Interface",
			      dbus_interface=dbus.PROPERTIES_IFACE)
	print
	print "GetAll(fi.w1.wpa_supplicant1.Interface, %s):" % (path)
	print props

	props = if_obj.GetAll("fi.w1.wpa_supplicant1.Interface.WPS",
			      dbus_interface=dbus.PROPERTIES_IFACE)
	print
	print "GetAll(fi.w1.wpa_supplicant1.Interface.WPS, %s):" % (path)
	print props

	res = if_obj.Get("fi.w1.wpa_supplicant1.Interface", 'BSSs',
			 dbus_interface=dbus.PROPERTIES_IFACE)
	if len(res) > 0:
		bss_obj = bus.get_object("fi.w1.wpa_supplicant1", res[0])
		props = bss_obj.GetAll("fi.w1.wpa_supplicant1.BSS",
				       dbus_interface=dbus.PROPERTIES_IFACE)
		print
		print "GetAll(fi.w1.wpa_supplicant1.BSS, %s):" % (res[0])
		print props

	res = if_obj.Get("fi.w1.wpa_supplicant1.Interface", 'Networks',
			 dbus_interface=dbus.PROPERTIES_IFACE)
	if len(res) > 0:
		net_obj = bus.get_object("fi.w1.wpa_supplicant1", res[0])
		props = net_obj.GetAll("fi.w1.wpa_supplicant1.Network",
				       dbus_interface=dbus.PROPERTIES_IFACE)
		print
		print "GetAll(fi.w1.wpa_supplicant1.Network, %s):" % (res[0])
		print props

if __name__ == "__main__":
	main()