Chromium Code Reviews| 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) |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 "org.chromium.flimflam.Service") | 26 "org.chromium.flimflam.Service") |
| 27 except Exception, e: | 27 except Exception, e: |
| 28 print "FAIL(GetService): ssid %s exception %s" %(ssid, e) | 28 print "FAIL(GetService): ssid %s exception %s" %(ssid, e) |
| 29 sys.exit(1) | 29 sys.exit(1) |
| 30 | 30 |
| 31 return (path, service) | 31 return (path, service) |
| 32 | 32 |
| 33 | 33 |
| 34 def ParseProps(props): | 34 def ParseProps(props): |
| 35 proplist = [] | 35 proplist = [] |
| 36 for p in props: | 36 if props is not None: |
| 37 proplist.append("'%s': '%s'" % (str(p), str(props[p]))) | 37 for p in props: |
| 38 return '{ %s }' % ', '.join(proplist) | 38 proplist.append("'%s': '%s'" % (str(p), str(props[p]))) |
| 39 return '{ %s }' % ', '.join(proplist) | |
| 40 else: | |
| 41 return 'None' | |
| 39 | 42 |
| 40 | 43 |
| 41 def ResetService(init_state): | 44 def ResetService(init_state): |
| 42 wait_time = 0 | 45 wait_time = 0 |
| 43 | 46 |
| 44 if init_state == 'idle': | 47 if init_state == 'idle': |
| 45 # If we are already idle, we have nothing to do | 48 # If we are already idle, we have nothing to do |
| 46 return | 49 return |
| 47 if init_state == 'ready': | 50 if init_state == 'ready': |
| 48 # flimflam is already connected. Disconnect. | 51 # flimflam is already connected. Disconnect. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 78 connect_quirks['lost_dbus'] = 1 | 81 connect_quirks['lost_dbus'] = 1 |
| 79 print>>sys.stderr, "We just lost the service handle!" | 82 print>>sys.stderr, "We just lost the service handle!" |
| 80 return (None, 'DBUSFAIL') | 83 return (None, 'DBUSFAIL') |
| 81 | 84 |
| 82 ResetService(init_state) | 85 ResetService(init_state) |
| 83 | 86 |
| 84 # print "INIT_STATUS1: %s" % service.GetProperties().get("State", None) | 87 # print "INIT_STATUS1: %s" % service.GetProperties().get("State", None) |
| 85 | 88 |
| 86 try: | 89 try: |
| 87 service.Connect() | 90 service.Connect() |
| 88 except org.chromium.flimflam.Error.InProgress, e: | 91 except dbus.exceptions.DBusException, e: |
| 89 # We can hope that a ResetService in the next call will solve this | 92 if e.get_dbus_name() == 'org.chromium.flimflam.Error.InProgress': |
| 90 connect_quirks['in_progress'] = 1 | 93 # We can hope that a ResetService in the next call will solve this |
| 91 print>>sys.stderr, "Previous connect is still in progress!" | 94 connect_quirks['in_progress'] = 1 |
| 92 time.sleep(.5) | 95 print>>sys.stderr, "Previous connect is still in progress!" |
| 93 return (None, 'FAIL') | 96 time.sleep(5) |
|
Sam Leffler
2010/06/11 22:11:01
These arbitrary sleeps will skew results. But I g
| |
| 97 return (None, 'FAIL') | |
| 98 # What is this exception? | |
| 99 print "FAIL(Connect): ssid %s DBus exception %s" %(ssid, e) | |
| 100 sys.exit(2) | |
| 94 except Exception, e: | 101 except Exception, e: |
| 95 print "FAIL(Connect): ssid %s exception %s" %(ssid, e) | 102 print "FAIL(Connect): ssid %s exception %s" %(ssid, e) |
| 96 sys.exit(2) | 103 sys.exit(2) |
| 97 | 104 |
| 98 properties = None | 105 properties = None |
| 99 # wait up to assoc_timeout seconds to associate | 106 # wait up to assoc_timeout seconds to associate |
| 100 while assoc_time < assoc_timeout: | 107 while assoc_time < assoc_timeout: |
| 101 properties = service.GetProperties() | 108 properties = service.GetProperties() |
| 102 status = properties.get("State", None) | 109 status = properties.get("State", None) |
| 103 # print>>sys.stderr, "time %3.1f state %s" % (assoc_time, status) | 110 # print>>sys.stderr, "time %3.1f state %s" % (assoc_time, status) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 if config_time >= config_timeout: | 198 if config_time >= config_timeout: |
| 192 print "TIMEOUT(config): ssid %s assoc %3.1f config %3.1f secs" \ | 199 print "TIMEOUT(config): ssid %s assoc %3.1f config %3.1f secs" \ |
| 193 %(ssid, assoc_time, config_time) | 200 %(ssid, assoc_time, config_time) |
| 194 DumpLogs(logs) | 201 DumpLogs(logs) |
| 195 sys.exit(6) | 202 sys.exit(6) |
| 196 | 203 |
| 197 print "OK %3.1f %3.1f %s (assoc and config times in sec, quirks)" \ | 204 print "OK %3.1f %3.1f %s (assoc and config times in sec, quirks)" \ |
| 198 %(assoc_time, config_time, str(connect_quirks.keys())) | 205 %(assoc_time, config_time, str(connect_quirks.keys())) |
| 199 sys.exit(0) | 206 sys.exit(0) |
| 200 | 207 |
| OLD | NEW |