| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 158 |
| 159 def main(argv): | 159 def main(argv): |
| 160 parser = optparse.OptionParser('Usage: %prog [options...] ' | 160 parser = optparse.OptionParser('Usage: %prog [options...] ' |
| 161 'ssid security psk assoc_timeout cfg_timeout') | 161 'ssid security psk assoc_timeout cfg_timeout') |
| 162 parser.add_option('--hidden', dest='hidden', action='store_true', | 162 parser.add_option('--hidden', dest='hidden', action='store_true', |
| 163 help='This is a hidden network') | 163 help='This is a hidden network') |
| 164 parser.add_option('--debug', dest='debug', action='store_true', | 164 parser.add_option('--debug', dest='debug', action='store_true', |
| 165 help='Report state changes and other debug info') | 165 help='Report state changes and other debug info') |
| 166 parser.add_option('--find_timeout', dest='find_timeout', type='int', | 166 parser.add_option('--find_timeout', dest='find_timeout', type='int', |
| 167 default=10, help='This is a hidden network') | 167 default=10, help='This is a hidden network') |
| 168 parser.add_option('--mode', dest='mode', default='managed', |
| 169 help='This is a hidden network') |
| 168 (options, args) = parser.parse_args(argv[1:]) | 170 (options, args) = parser.parse_args(argv[1:]) |
| 169 | 171 |
| 170 if len(argv) <= 4: | 172 if len(argv) <= 4: |
| 171 parser.error('Required arguments: ssid security psk assoc_timeount ' | 173 parser.error('Required arguments: ssid security psk assoc_timeount ' |
| 172 'config_timeout') | 174 'config_timeout') |
| 173 | 175 |
| 174 ssid = args[0] | 176 ssid = args[0] |
| 175 security = args[1] | 177 security = args[1] |
| 176 psk = args[2] | 178 psk = args[2] |
| 177 assoc_timeout = float(args[3]) | 179 assoc_timeout = float(args[3]) |
| 178 config_timeout = float(args[4]) | 180 config_timeout = float(args[4]) |
| 179 | 181 |
| 180 connection_settings = { | 182 connection_settings = { |
| 181 'Type': 'wifi', | 183 'Type': 'wifi', |
| 182 'Mode': 'managed', | 184 'Mode': options.mode, |
| 183 'SSID': ssid, | 185 'SSID': ssid, |
| 184 'Security': security | 186 'Security': security |
| 185 } | 187 } |
| 186 | 188 |
| 187 if security == '802_1x': | 189 if security == '802_1x': |
| 188 cert_args = psk.split(':') | 190 cert_args = psk.split(':') |
| 189 for i in xrange(0, len(cert_args), 2): | 191 for i in xrange(0, len(cert_args), 2): |
| 190 connection_settings[cert_args[i]] = cert_args[i+1] | 192 connection_settings[cert_args[i]] = cert_args[i+1] |
| 191 else: | 193 else: |
| 192 connection_settings['Passphrase'] = psk | 194 connection_settings['Passphrase'] = psk |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 (acquire_time, wpa_select_time, assoc_time, config_time, | 256 (acquire_time, wpa_select_time, assoc_time, config_time, |
| 255 handler.frequency, handler.phymode, handler.security, | 257 handler.frequency, handler.phymode, handler.security, |
| 256 str(connect_quirks.keys()))) | 258 str(connect_quirks.keys()))) |
| 257 | 259 |
| 258 if connect_quirks: | 260 if connect_quirks: |
| 259 DumpLogs(logs) | 261 DumpLogs(logs) |
| 260 sys.exit(0) | 262 sys.exit(0) |
| 261 | 263 |
| 262 if __name__ == '__main__': | 264 if __name__ == '__main__': |
| 263 main(sys.argv) | 265 main(sys.argv) |
| OLD | NEW |