Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: server/site_wlan_connect.py

Issue 3441029: AP scan on correct wifi interfaces when dumping logs. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 msgs = open(logfile) 152 msgs = open(logfile)
153 msgs.seek(0, 2) 153 msgs.seek(0, 2)
154 logs.append({ 'name': logfile, 'file': msgs }) 154 logs.append({ 'name': logfile, 'file': msgs })
155 except Exception, e: 155 except Exception, e:
156 # If we cannot open the file, this is not necessarily an error 156 # If we cannot open the file, this is not necessarily an error
157 pass 157 pass
158 158
159 return logs 159 return logs
160 160
161 161
162 # Returns the list of the wifi interfaces (e.g. "wlan0") known to flimflam
163 def GetWifiInterfaces():
164 interfaces = []
165 device_paths = manager.GetProperties().get("Devices", None)
166 for device_path in device_paths:
167 device = dbus.Interface(
168 bus.get_object("org.chromium.flimflam", device_path),
169 "org.chromium.flimflam.Device")
170 props = device.GetProperties()
171 type = props.get("Type", None)
172 interface = props.get("Interface", None)
173 if type == "wifi":
174 interfaces.append(interface)
175 return interfaces
176
162 def DumpLogs(logs): 177 def DumpLogs(logs):
163 for log in logs: 178 for log in logs:
164 print>>sys.stderr, "Content of %s during our run:" % log['name'] 179 print>>sys.stderr, "Content of %s during our run:" % log['name']
165 print>>sys.stderr, " ))) ".join(log['file'].readlines()) 180 print>>sys.stderr, " ))) ".join(log['file'].readlines())
166 181
167 print>>sys.stderr, "iw dev wlan0 scan output: %s" % \ 182 for interface in GetWifiInterfaces():
168 subprocess.Popen(["iw", "dev", "wlan0", "scan"], 183 print>>sys.stderr, "iw dev %s scan output: %s" % \
169 stdout=subprocess.PIPE).communicate()[0] 184 ( interface,
185 subprocess.Popen(["iw", "dev", interface, "scan"],
186 stdout=subprocess.PIPE).communicate()[0])
170 187
171 def ErrExit(code): 188 def ErrExit(code):
172 try: 189 try:
173 service.Disconnect() 190 service.Disconnect()
174 except: 191 except:
175 pass 192 pass
176 DumpLogs(logs) 193 DumpLogs(logs)
177 sys.exit(code) 194 sys.exit(code)
178 195
179 logs = OpenLogs('/var/log/messages', '/var/log/hostap.log') 196 logs = OpenLogs('/var/log/messages', '/var/log/hostap.log')
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 print "TIMEOUT(config): ssid %s assoc %3.1f config %3.1f secs" \ 241 print "TIMEOUT(config): ssid %s assoc %3.1f config %3.1f secs" \
225 %(ssid, assoc_time, config_time) 242 %(ssid, assoc_time, config_time)
226 ErrExit(6) 243 ErrExit(6)
227 244
228 print "OK %3.1f %3.1f %s (assoc and config times in sec, quirks)" \ 245 print "OK %3.1f %3.1f %s (assoc and config times in sec, quirks)" \
229 %(assoc_time, config_time, str(connect_quirks.keys())) 246 %(assoc_time, config_time, str(connect_quirks.keys()))
230 247
231 if connect_quirks: 248 if connect_quirks:
232 DumpLogs(logs) 249 DumpLogs(logs)
233 sys.exit(0) 250 sys.exit(0)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698