OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 """Connect to a WiFi service and report the amount of time it took | 3 """Connect to a WiFi service and report the amount of time it took |
4 | 4 |
5 This script initiates a connection to a WiFi service and reports | 5 This script initiates a connection to a WiFi service and reports |
6 the time to major state changes (assoc, config). If the connection | 6 the time to major state changes (assoc, config). If the connection |
7 fails within the desired time, it outputs the contents of the log | 7 fails within the desired time, it outputs the contents of the log |
8 files during that intervening time. | 8 files during that intervening time. |
9 | 9 |
10 """ | 10 """ |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 self.bus.add_signal_receiver(self.SupplicantChangeCallback, | 57 self.bus.add_signal_receiver(self.SupplicantChangeCallback, |
58 signal_name='PropertiesChanged', | 58 signal_name='PropertiesChanged', |
59 dbus_interface=SUPPLICANT+'.Interface') | 59 dbus_interface=SUPPLICANT+'.Interface') |
60 | 60 |
61 def FindService(self, path_list=None): | 61 def FindService(self, path_list=None): |
62 service = None | 62 service = None |
63 for svc in FindObjects('Service', 'SSID', self.service_name, | 63 for svc in FindObjects('Service', 'SSID', self.service_name, |
64 path_list=path_list): | 64 path_list=path_list): |
65 props = svc.GetProperties() | 65 props = svc.GetProperties() |
| 66 set_props = {} |
66 for key, val in self.connection_settings.items(): | 67 for key, val in self.connection_settings.items(): |
67 prop_val = convert_dbus_value(props.get(key)) | 68 prop_val = convert_dbus_value(props.get(key)) |
68 if key != 'SSID' and prop_val != val: | 69 if key != 'SSID' and prop_val != val: |
69 if key in ['Passphrase', 'SaveCredentials'] or key.startswith('EAP.'): | 70 if key in ['Passphrase', 'SaveCredentials'] or key.startswith('EAP.'): |
70 try: | 71 set_props[key] = val |
71 svc.SetProperty(key, val) | |
72 except dbus.exceptions.DBusException, e: | |
73 self.failure = ('SetProperty: DBus exception %s for set of %s' % | |
74 (e, key)) | |
75 return None | |
76 else: | 72 else: |
77 self.Debug('Service key mismatch: %s %s != %s' % | 73 self.Debug('Service key mismatch: %s %s != %s' % |
78 (key, val, str(prop_val))) | 74 (key, val, str(prop_val))) |
79 break | 75 break |
80 else: | 76 else: |
| 77 for key, val in set_props.iteritems(): |
| 78 try: |
| 79 svc.SetProperty(key, val) |
| 80 except dbus.exceptions.DBusException, e: |
| 81 self.failure = ('SetProperty: DBus exception %s for set of %s' % |
| 82 (e, key)) |
| 83 return None |
81 service = svc | 84 service = svc |
82 if self.scan_timeout is not None: | 85 if self.scan_timeout is not None: |
83 gobject.source_remove(self.scan_timeout) | 86 gobject.source_remove(self.scan_timeout) |
84 self.scan_timeout = None | 87 self.scan_timeout = None |
85 break | 88 break |
86 else: | 89 else: |
87 if self.hidden: | 90 if self.hidden: |
88 try: | 91 try: |
89 path = manager.GetService((self.connection_settings)) | 92 path = manager.GetService((self.connection_settings)) |
90 service = dbus.Interface( | 93 service = dbus.Interface( |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 (acquire_time, wpa_select_time, assoc_time, config_time, | 272 (acquire_time, wpa_select_time, assoc_time, config_time, |
270 handler.frequency, handler.phymode, handler.security, | 273 handler.frequency, handler.phymode, handler.security, |
271 str(connect_quirks.keys()))) | 274 str(connect_quirks.keys()))) |
272 | 275 |
273 if connect_quirks: | 276 if connect_quirks: |
274 DumpLogs(logs) | 277 DumpLogs(logs) |
275 sys.exit(0) | 278 sys.exit(0) |
276 | 279 |
277 if __name__ == '__main__': | 280 if __name__ == '__main__': |
278 main(sys.argv) | 281 main(sys.argv) |
OLD | NEW |