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

Side by Side Diff: build/android/buildbot/bb_device_status_check.py

Issue 1337463002: [Android] Fix low-battery blacklisting in device_status_check. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« 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 #!/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 8
9 import argparse 9 import argparse
10 import json 10 import json
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 battery = battery_utils.BatteryUtils(device) 61 battery = battery_utils.BatteryUtils(device)
62 battery_info = battery.GetBatteryInfo(timeout=5) 62 battery_info = battery.GetBatteryInfo(timeout=5)
63 battery_level = int(battery_info.get('level', 100)) 63 battery_level = int(battery_info.get('level', 100))
64 64
65 if battery_level < 15: 65 if battery_level < 15:
66 logging.error('Critically low battery level (%d)', battery_level) 66 logging.error('Critically low battery level (%d)', battery_level)
67 battery = battery_utils.BatteryUtils(device) 67 battery = battery_utils.BatteryUtils(device)
68 if not battery.GetCharging(): 68 if not battery.GetCharging():
69 battery.SetCharging(True) 69 battery.SetCharging(True)
70 if blacklist: 70 if blacklist:
71 blacklist.Extend([device.GetDeviceSerial()]) 71 blacklist.Extend([device.adb.GetDeviceSerial()])
72 72
73 except device_errors.CommandFailedError: 73 except device_errors.CommandFailedError:
74 logging.exception('Failed to get battery information for %s', 74 logging.exception('Failed to get battery information for %s',
75 str(device)) 75 str(device))
76 76
77 return battery_info 77 return battery_info
78 78
79 79
80 def _IMEISlice(device): 80 def _IMEISlice(device):
81 imei_slice = '' 81 imei_slice = ''
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 device_errors.CommandFailedError): 248 device_errors.CommandFailedError):
249 logging.exception('Failure while waiting for %s. ' 249 logging.exception('Failure while waiting for %s. '
250 'Attempting to recover.', str(device)) 250 'Attempting to recover.', str(device))
251 251
252 try: 252 try:
253 device.Reboot() 253 device.Reboot()
254 device.WaitUntilFullyBooted() 254 device.WaitUntilFullyBooted()
255 except device_errors.CommandFailedError: 255 except device_errors.CommandFailedError:
256 logging.exception('Failure while waiting for %s.', str(device)) 256 logging.exception('Failure while waiting for %s.', str(device))
257 if blacklist: 257 if blacklist:
258 blacklist.Extend([str(device)]) 258 blacklist.Extend([device.adb.GetDeviceSerial()])
259 except device_errors.CommandTimeoutError: 259 except device_errors.CommandTimeoutError:
260 logging.exception('Timed out while waiting for %s. ', str(device)) 260 logging.exception('Timed out while waiting for %s. ', str(device))
261 if blacklist: 261 if blacklist:
262 blacklist.Extend([str(device)]) 262 blacklist.Extend([device.adb.GetDeviceSerial()])
263 263
264 device_utils.DeviceUtils.parallel(devices).pMap(blacklisting_recovery) 264 device_utils.DeviceUtils.parallel(devices).pMap(blacklisting_recovery)
265 265
266 266
267 def main(): 267 def main():
268 parser = argparse.ArgumentParser() 268 parser = argparse.ArgumentParser()
269 parser.add_argument('--out-dir', 269 parser.add_argument('--out-dir',
270 help='Directory where the device path is stored', 270 help='Directory where the device path is stored',
271 default=os.path.join(constants.DIR_SOURCE_ROOT, 'out')) 271 default=os.path.join(constants.DIR_SOURCE_ROOT, 'out'))
272 parser.add_argument('--restart-usb', action='store_true', 272 parser.add_argument('--restart-usb', action='store_true',
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 live_devices = [status['serial'] for status in statuses 359 live_devices = [status['serial'] for status in statuses
360 if (status['adb_status'] == 'device' 360 if (status['adb_status'] == 'device'
361 and status['serial'] not in blacklist.Read())] 361 and status['serial'] not in blacklist.Read())]
362 362
363 # If all devices failed, or if there are no devices, it's an infra error. 363 # If all devices failed, or if there are no devices, it's an infra error.
364 return 0 if live_devices else constants.INFRA_EXIT_CODE 364 return 0 if live_devices else constants.INFRA_EXIT_CODE
365 365
366 366
367 if __name__ == '__main__': 367 if __name__ == '__main__':
368 sys.exit(main()) 368 sys.exit(main())
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