wpas-dbus-new-getall.py 1.7 KB

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