| #!/usr/bin/python | |
| import dbus | |
| import time | |
| WPA_NAME='fi.epitest.hostap.WPASupplicant' | |
| WPA_INTF='fi.epitest.hostap.WPASupplicant' | |
| WPA_PATH='/fi/epitest/hostap/WPASupplicant' | |
| bus = dbus.SystemBus() | |
| dummy = dbus.Interface(bus.get_object(WPA_NAME, WPA_PATH), | |
| 'org.freedesktop.DBus.Introspectable') | |
| #print dummy.Introspect() | |
| manager = dbus.Interface(bus.get_object(WPA_NAME, WPA_PATH), WPA_INTF) | |
| try: | |
| path = manager.getInterface("wlan0") | |
| except: | |
| path = manager.addInterface("wlan0") | |
| interface = dbus.Interface(bus.get_object(WPA_NAME, path), | |
| WPA_INTF + ".Interface") | |
| print "state = %s" % (interface.state()) | |
| try: | |
| print "scanning = %s" % (interface.scanning()) | |
| except: | |
| pass | |
| print "[ %s ]" % (path) | |
| capabilities = interface.capabilities() | |
| for key in capabilities.keys(): | |
| list = "" | |
| for value in capabilities[key]: | |
| list += " " + value | |
| print " %s =%s" % (key, list) | |
| interface.scan() | |
| time.sleep(1) | |
| try: | |
| print "scanning = %s" % (interface.scanning()) | |
| except: | |
| pass | |
| time.sleep(1) | |
| print "state = %s" % (interface.state()) | |
| results = interface.scanResults() | |
| print results | |
| path = results[0] | |
| print "[ %s ]" % (path) | |
| bssid = dbus.Interface(bus.get_object(WPA_NAME, path), | |
| WPA_INTF + ".BSSID") | |
| properties = bssid.properties() | |
| for key in properties.keys(): | |
| print " %s = %s" % (key, properties[key]) |