| #!/usr/bin/python |
| |
| import dbus, flimflam, string, sys |
| |
| if (len(sys.argv) < 3): |
| print "Usage: %s <network-name> <passphrase>" % (sys.argv[0]) |
| sys.exit(1) |
| |
| (_, name, passphrase) = sys.argv |
| |
| flim = flimflam.FlimFlam(dbus.SystemBus()) |
| |
| for device in flim.GetObjectList("Device"): |
| device_properties = device.GetProperties(utf8_strings = True) |
| |
| if device_properties["Type"] not in ["wifi", "wimax"]: |
| continue; |
| |
| for network in flim.GetObjectList("Network", device_properties): |
| network_properties = network.GetProperties(utf8_strings = True) |
| |
| if network_properties.get("Name", None) == name: |
| print "Setting passphrase for %s" % (path) |
| network.SetProperty("WiFi.Passphrase", passphrase) |