| #!/usr/bin/env python3 | |
| # Copyright 2019 The ChromiumOS Authors | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| from __future__ import print_function | |
| import sys | |
| import dbus | |
| import flimflam | |
| if len(sys.argv) < 2: | |
| print('Usage: %s <GUID> [<property> <value>]' % (sys.argv[0])) | |
| sys.exit(1) | |
| print('Attempting to configure service %s' % (sys.argv[1])) | |
| flim = flimflam.FlimFlam(dbus.SystemBus()) | |
| params = {'GUID': sys.argv[1]} | |
| argv = sys.argv[2:] | |
| while argv: | |
| property_key = argv[0] | |
| value = argv[1] | |
| if property_key in ['Priority']: | |
| params[property_key] = int(value) | |
| elif property_key in ['AutoConnect', 'WiFi.HiddenSSID', 'EAP.UseSystemCAS', | |
| 'SaveCredentials']: | |
| params[property_key] = dbus.Boolean(value.lower() in ('true', '1')) | |
| else: | |
| params[property_key] = value | |
| argv = argv[2:] | |
| service = flim.GetService(params) | |
| properties = service.GetProperties() | |
| print('[ %s ]' % (service.object_path)) | |
| for key in properties.keys(): | |
| print(' %s = %s' % | |
| (key, flimflam.convert_dbus_value(properties[key], 4))) | |
| print('') |