OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """A class to keep track of devices across builds and report state.""" | 7 """A class to keep track of devices across builds and report state.""" |
8 import logging | 8 import logging |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
11 import smtplib | 11 import smtplib |
12 import sys | 12 import sys |
13 import re | 13 import re |
14 | 14 |
15 from pylib import android_commands | 15 from pylib import android_commands |
16 from pylib import buildbot_report | 16 from pylib import buildbot_report |
17 from pylib import constants | 17 from pylib import constants |
18 from pylib.cmd_helper import GetCmdOutput | 18 from pylib.cmd_helper import GetCmdOutput |
19 | 19 |
20 | 20 |
21 def DeviceInfo(serial): | 21 def DeviceInfo(serial, options): |
22 """Gathers info on a device via various adb calls. | 22 """Gathers info on a device via various adb calls. |
23 | 23 |
24 Args: | 24 Args: |
25 serial: The serial of the attached device to construct info about. | 25 serial: The serial of the attached device to construct info about. |
26 | 26 |
27 Returns: | 27 Returns: |
28 Tuple of device type, build id, report as a string, error messages, and | 28 Tuple of device type, build id, report as a string, error messages, and |
29 boolean indicating whether or not device can be used for testing. | 29 boolean indicating whether or not device can be used for testing. |
30 """ | 30 """ |
31 | 31 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 ' IMEI slice: %s' % AdbShellCmd('dumpsys iphonesubinfo ' | 68 ' IMEI slice: %s' % AdbShellCmd('dumpsys iphonesubinfo ' |
69 '| grep Device' | 69 '| grep Device' |
70 "| awk '{print $4}'")[-6:], | 70 "| awk '{print $4}'")[-6:], |
71 ' Wifi IP: %s' % AdbShellCmd('getprop dhcp.wlan0.ipaddress'), | 71 ' Wifi IP: %s' % AdbShellCmd('getprop dhcp.wlan0.ipaddress'), |
72 ' Install Speed: %s KB/s' % install_speed, | 72 ' Install Speed: %s KB/s' % install_speed, |
73 ''] | 73 ''] |
74 | 74 |
75 errors = [] | 75 errors = [] |
76 if battery_level < 15: | 76 if battery_level < 15: |
77 errors += ['Device critically low in battery. Turning off device.'] | 77 errors += ['Device critically low in battery. Turning off device.'] |
78 if not setup_wizard_disabled and device_build_type != 'user': | 78 if (not setup_wizard_disabled and device_build_type != 'user' and |
| 79 not options.no_provisioning_check): |
79 errors += ['Setup wizard not disabled. Was it provisioned correctly?'] | 80 errors += ['Setup wizard not disabled. Was it provisioned correctly?'] |
80 if device_product_name == 'mantaray' and ac_power != 'true': | 81 if device_product_name == 'mantaray' and ac_power != 'true': |
81 errors += ['Mantaray device not connected to AC power.'] | 82 errors += ['Mantaray device not connected to AC power.'] |
82 # TODO(navabi): Insert warning once we have a better handle of what install | 83 # TODO(navabi): Insert warning once we have a better handle of what install |
83 # speeds to expect. The following lines were causing too many alerts. | 84 # speeds to expect. The following lines were causing too many alerts. |
84 # if install_speed < 500: | 85 # if install_speed < 500: |
85 # errors += ['Device install speed too low. Do not use for testing.'] | 86 # errors += ['Device install speed too low. Do not use for testing.'] |
86 | 87 |
87 # Causing the device status check step fail for slow install speed or low | 88 # Causing the device status check step fail for slow install speed or low |
88 # battery currently is too disruptive to the bots (especially try bots). | 89 # battery currently is too disruptive to the bots (especially try bots). |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 except Exception as e: | 179 except Exception as e: |
179 print 'Failed to send alert email. Error: %s' % e | 180 print 'Failed to send alert email. Error: %s' % e |
180 | 181 |
181 | 182 |
182 def main(): | 183 def main(): |
183 parser = optparse.OptionParser() | 184 parser = optparse.OptionParser() |
184 parser.add_option('', '--out-dir', | 185 parser.add_option('', '--out-dir', |
185 help='Directory where the device path is stored', | 186 help='Directory where the device path is stored', |
186 default=os.path.join(os.path.dirname(__file__), '..', | 187 default=os.path.join(os.path.dirname(__file__), '..', |
187 '..', 'out')) | 188 '..', 'out')) |
| 189 parser.add_option('--no-provisioning-check', |
| 190 help='Will not check if devices are provisioned properly.') |
188 | 191 |
189 options, args = parser.parse_args() | 192 options, args = parser.parse_args() |
190 if args: | 193 if args: |
191 parser.error('Unknown options %s' % args) | 194 parser.error('Unknown options %s' % args) |
192 devices = android_commands.GetAttachedDevices() | 195 devices = android_commands.GetAttachedDevices() |
193 types, builds, reports, errors = [], [], [], [] | 196 types, builds, reports, errors = [], [], [], [] |
194 fail_step_lst = [] | 197 fail_step_lst = [] |
195 if devices: | 198 if devices: |
196 types, builds, reports, errors, fail_step_lst = zip(*[DeviceInfo(dev) | 199 types, builds, reports, errors, fail_step_lst = ( |
197 for dev in devices]) | 200 zip(*[DeviceInfo(dev, options) for dev in devices])) |
198 | 201 |
199 err_msg = CheckForMissingDevices(options, devices) or [] | 202 err_msg = CheckForMissingDevices(options, devices) or [] |
200 | 203 |
201 unique_types = list(set(types)) | 204 unique_types = list(set(types)) |
202 unique_builds = list(set(builds)) | 205 unique_builds = list(set(builds)) |
203 | 206 |
204 buildbot_report.PrintMsg('Online devices: %d. Device types %s, builds %s' | 207 buildbot_report.PrintMsg('Online devices: %d. Device types %s, builds %s' |
205 % (len(devices), unique_types, unique_builds)) | 208 % (len(devices), unique_types, unique_builds)) |
206 print '\n'.join(reports) | 209 print '\n'.join(reports) |
207 | 210 |
(...skipping 13 matching lines...) Expand all Loading... |
221 # devices with critically low battery or install speed. Remove those devices | 224 # devices with critically low battery or install speed. Remove those devices |
222 # from testing, allowing build to continue with good devices. | 225 # from testing, allowing build to continue with good devices. |
223 return 1 | 226 return 1 |
224 | 227 |
225 if not devices: | 228 if not devices: |
226 return 1 | 229 return 1 |
227 | 230 |
228 | 231 |
229 if __name__ == '__main__': | 232 if __name__ == '__main__': |
230 sys.exit(main()) | 233 sys.exit(main()) |
OLD | NEW |