Christopher Wiley | 2f48d95 | 2013-02-22 09:51:47 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | import dbus |
| 4 | import flimflam |
| 5 | import sys |
| 6 | |
| 7 | if len(sys.argv) < 2: |
| 8 | print "Usage: %s <GUID> [<property> <value>]" % (sys.argv[0]) |
| 9 | sys.exit(1) |
| 10 | |
| 11 | print "Attempting to configure service %s" % (sys.argv[1]) |
| 12 | |
| 13 | flim = flimflam.FlimFlam(dbus.SystemBus()) |
| 14 | |
| 15 | params = { "GUID" : sys.argv[1] } |
| 16 | argv = sys.argv[2:] |
| 17 | while argv: |
| 18 | property_key = argv[0] |
| 19 | value = argv[1] |
| 20 | if property_key in ["Priority"]: |
| 21 | params[property_key] = int(value) |
| 22 | elif property_key in ["AutoConnect", "WiFi.HiddenSSID", "EAP.UseSystemCAS", |
| 23 | "SaveCredentials"]: |
| 24 | params[property_key] = dbus.Boolean(value.lower() in ("true", "1")) |
| 25 | else: |
| 26 | params[property_key] = value |
| 27 | |
| 28 | argv = argv[2:] |
| 29 | |
| 30 | service = flim.GetService(params) |
| 31 | properties = service.GetProperties(utf8_strings = True) |
| 32 | |
| 33 | print "[ %s ]" % (service.object_path) |
| 34 | |
| 35 | for key in properties.keys(): |
| 36 | print " %s = %s" % \ |
| 37 | (key, flimflam.convert_dbus_value(properties[key], 4)) |
| 38 | |
| 39 | print |