OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 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 import urllib |
14 | 15 |
15 import bb_annotations | 16 import bb_annotations |
16 | 17 |
17 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 18 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
18 from pylib import android_commands | 19 from pylib import android_commands |
19 from pylib import constants | 20 from pylib import constants |
20 from pylib import perf_tests_helper | 21 from pylib import perf_tests_helper |
21 from pylib.cmd_helper import GetCmdOutput | 22 from pylib.cmd_helper import GetCmdOutput |
22 | 23 |
23 | 24 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 if not all_known_devices: | 142 if not all_known_devices: |
142 # This can happen if for some reason the .last_devices file is not | 143 # This can happen if for some reason the .last_devices file is not |
143 # present or if it was empty. | 144 # present or if it was empty. |
144 return ['No online devices. Have any devices been plugged in?'] | 145 return ['No online devices. Have any devices been plugged in?'] |
145 if missing_devs: | 146 if missing_devs: |
146 devices_missing_msg = '%d devices not detected.' % len(missing_devs) | 147 devices_missing_msg = '%d devices not detected.' % len(missing_devs) |
147 bb_annotations.PrintSummaryText(devices_missing_msg) | 148 bb_annotations.PrintSummaryText(devices_missing_msg) |
148 | 149 |
149 # TODO(navabi): Debug by printing both output from GetCmdOutput and | 150 # TODO(navabi): Debug by printing both output from GetCmdOutput and |
150 # GetAttachedDevices to compare results. | 151 # GetAttachedDevices to compare results. |
| 152 crbug_link = ('https://code.google.com/p/chromium/issues/entry?summary=' |
| 153 '%s&comment=%s&labels=Restrict-View-Google,OS-Android,Infra' % |
| 154 (urllib.quote('Device Offline'), |
| 155 urllib.quote('Buildbot: %s %s\n' |
| 156 'Build: %s\n' |
| 157 '(please don\'t change any labels)' % |
| 158 (os.environ.get('BUILDBOT_BUILDERNAME'), |
| 159 os.environ.get('BUILDBOT_SLAVENAME'), |
| 160 os.environ.get('BUILDBOT_BUILDNUMBER'))))) |
151 return ['Current online devices: %s' % adb_online_devs, | 161 return ['Current online devices: %s' % adb_online_devs, |
152 '%s are no longer visible. Were they removed?\n' % missing_devs, | 162 '%s are no longer visible. Were they removed?\n' % missing_devs, |
153 'SHERIFF: See go/chrome_device_monitor', | 163 'SHERIFF:\n', |
| 164 '@@@STEP_LINK@Click here to file a bug@%s@@@\n' % crbug_link, |
154 'Cache file: %s\n\n' % last_devices_path, | 165 'Cache file: %s\n\n' % last_devices_path, |
155 'adb devices: %s' % GetCmdOutput(['adb', 'devices']), | 166 'adb devices: %s' % GetCmdOutput(['adb', 'devices']), |
156 'adb devices(GetAttachedDevices): %s' % | 167 'adb devices(GetAttachedDevices): %s' % |
157 android_commands.GetAttachedDevices()] | 168 android_commands.GetAttachedDevices()] |
158 else: | 169 else: |
159 new_devs = set(adb_online_devs) - set(last_devices) | 170 new_devs = set(adb_online_devs) - set(last_devices) |
160 if new_devs and os.path.exists(last_devices_path): | 171 if new_devs and os.path.exists(last_devices_path): |
161 bb_annotations.PrintWarning() | 172 bb_annotations.PrintWarning() |
162 bb_annotations.PrintSummaryText( | 173 bb_annotations.PrintSummaryText( |
163 '%d new devices detected' % len(new_devs)) | 174 '%d new devices detected' % len(new_devs)) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 # devices with critically low battery or install speed. Remove those devices | 251 # devices with critically low battery or install speed. Remove those devices |
241 # from testing, allowing build to continue with good devices. | 252 # from testing, allowing build to continue with good devices. |
242 return 1 | 253 return 1 |
243 | 254 |
244 if not devices: | 255 if not devices: |
245 return 1 | 256 return 1 |
246 | 257 |
247 | 258 |
248 if __name__ == '__main__': | 259 if __name__ == '__main__': |
249 sys.exit(main()) | 260 sys.exit(main()) |
OLD | NEW |