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

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

Issue 284953002: If no battery information, do not try to split. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits. Created 6 years, 7 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 #!/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
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 logging.error('Unable to obtain battery info for %s, %s', serial, e) 56 logging.error('Unable to obtain battery info for %s, %s', serial, e)
57 57
58 def _GetData(re_expression, line, lambda_function=lambda x:x): 58 def _GetData(re_expression, line, lambda_function=lambda x:x):
59 if not line: 59 if not line:
60 return 'Unknown' 60 return 'Unknown'
61 found = re.findall(re_expression, line) 61 found = re.findall(re_expression, line)
62 if found and len(found): 62 if found and len(found):
63 return lambda_function(found[0]) 63 return lambda_function(found[0])
64 return 'Unknown' 64 return 'Unknown'
65 65
66 def _GetBatteryInfo(battery):
67 if not battery:
68 return 'No battery info.'
69 battery_info = battery.split('\n')
70 return battery_info[0] + '\n '.join(battery_info[1:])
71
66 ac_power = _GetData('AC powered: (\w+)', battery) 72 ac_power = _GetData('AC powered: (\w+)', battery)
67 battery_level = _GetData('level: (\d+)', battery) 73 battery_level = _GetData('level: (\d+)', battery)
68 imei_slice = _GetData('Device ID = (\d+)', 74 imei_slice = _GetData('Device ID = (\d+)',
69 device_adb.old_interface.GetSubscriberInfo(), 75 device_adb.old_interface.GetSubscriberInfo(),
70 lambda x: x[-6:]) 76 lambda x: x[-6:])
71 report = ['Device %s (%s)' % (serial, device_type), 77 report = ['Device %s (%s)' % (serial, device_type),
72 ' Build: %s (%s)' % 78 ' Build: %s (%s)' %
73 (device_build, device_adb.old_interface.GetBuildFingerprint()), 79 (device_build, device_adb.old_interface.GetBuildFingerprint()),
74 ' %s' % '\n '.join(battery.split('\n')), 80 ' %s' % _GetBatteryInfo(battery),
75 ' IMEI slice: %s' % imei_slice, 81 ' IMEI slice: %s' % imei_slice,
76 ' Wifi IP: %s' % device_adb.old_interface.GetWifiIP(), 82 ' Wifi IP: %s' % device_adb.old_interface.GetWifiIP(),
77 ''] 83 '']
78 84
79 errors = [] 85 errors = []
80 if battery_level < 15: 86 if battery_level < 15:
81 errors += ['Device critically low in battery. Turning off device.'] 87 errors += ['Device critically low in battery. Turning off device.']
82 if not options.no_provisioning_check: 88 if not options.no_provisioning_check:
83 setup_wizard_disabled = ( 89 setup_wizard_disabled = (
84 device_adb.old_interface.GetSetupWizardStatus() == 'DISABLED') 90 device_adb.old_interface.GetSetupWizardStatus() == 'DISABLED')
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 # devices with critically low battery. Remove those devices from testing, 352 # devices with critically low battery. Remove those devices from testing,
347 # allowing build to continue with good devices. 353 # allowing build to continue with good devices.
348 return 1 354 return 1
349 355
350 if not devices: 356 if not devices:
351 return 1 357 return 1
352 358
353 359
354 if __name__ == '__main__': 360 if __name__ == '__main__':
355 sys.exit(main()) 361 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