OLD | NEW |
1 import dbus, dbus.mainloop.glib, gobject, logging, re, sys, time, subprocess | 1 import dbus, dbus.mainloop.glib, gobject, logging, re, sys, time, subprocess |
2 | 2 |
3 ssid = sys.argv[1] | 3 ssid = sys.argv[1] |
4 security = sys.argv[2] | 4 security = sys.argv[2] |
5 psk = sys.argv[3] | 5 psk = sys.argv[3] |
6 assoc_timeout = float(sys.argv[4]) | 6 assoc_timeout = float(sys.argv[4]) |
7 config_timeout = float(sys.argv[5]) | 7 config_timeout = float(sys.argv[5]) |
8 reset_timeout = float(sys.argv[6]) if len(sys.argv) > 6 else assoc_timeout | 8 reset_timeout = float(sys.argv[6]) if len(sys.argv) > 6 else assoc_timeout |
9 | 9 |
10 bus_loop = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) | 10 bus_loop = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) |
11 bus = dbus.SystemBus(mainloop=bus_loop) | 11 bus = dbus.SystemBus(mainloop=bus_loop) |
12 manager = dbus.Interface(bus.get_object("org.chromium.flimflam", "/"), | 12 manager = dbus.Interface(bus.get_object("org.chromium.flimflam", "/"), |
13 "org.chromium.flimflam.Manager") | 13 "org.chromium.flimflam.Manager") |
14 connect_quirks = {} | 14 connect_quirks = {} |
15 | 15 |
| 16 connection_settings = { |
| 17 "Type": "wifi", |
| 18 "Mode": "managed", |
| 19 "SSID": ssid, |
| 20 "Security": security |
| 21 } |
| 22 |
| 23 if security == '802_1x': |
| 24 (connection_settings["Identity"], |
| 25 connection_settings["CertPath"]) = psk.split(':') |
| 26 else: |
| 27 connection_settings["Passphrase"] = psk |
| 28 |
16 def DbusSetup(): | 29 def DbusSetup(): |
17 try: | 30 try: |
18 path = manager.GetService(({ | 31 path = manager.GetService((connection_settings)) |
19 "Type": "wifi", | |
20 "Mode": "managed", | |
21 "SSID": ssid, | |
22 "Security": security, | |
23 "Passphrase": psk })) | |
24 service = dbus.Interface( | 32 service = dbus.Interface( |
25 bus.get_object("org.chromium.flimflam", path), | 33 bus.get_object("org.chromium.flimflam", path), |
26 "org.chromium.flimflam.Service") | 34 "org.chromium.flimflam.Service") |
27 except Exception, e: | 35 except Exception, e: |
28 print "FAIL(GetService): ssid %s exception %s" %(ssid, e) | 36 print "FAIL(GetService): ssid %s exception %s" %(ssid, e) |
29 sys.exit(1) | 37 sys.exit(1) |
30 | 38 |
31 return (path, service) | 39 return (path, service) |
32 | 40 |
33 | 41 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 if config_time >= config_timeout: | 212 if config_time >= config_timeout: |
205 print "TIMEOUT(config): ssid %s assoc %3.1f config %3.1f secs" \ | 213 print "TIMEOUT(config): ssid %s assoc %3.1f config %3.1f secs" \ |
206 %(ssid, assoc_time, config_time) | 214 %(ssid, assoc_time, config_time) |
207 DumpLogs(logs) | 215 DumpLogs(logs) |
208 sys.exit(6) | 216 sys.exit(6) |
209 | 217 |
210 print "OK %3.1f %3.1f %s (assoc and config times in sec, quirks)" \ | 218 print "OK %3.1f %3.1f %s (assoc and config times in sec, quirks)" \ |
211 %(assoc_time, config_time, str(connect_quirks.keys())) | 219 %(assoc_time, config_time, str(connect_quirks.keys())) |
212 sys.exit(0) | 220 sys.exit(0) |
213 | 221 |
OLD | NEW |