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

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

Issue 333723003: Wait for perfbot devices to charge between runs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fail high when battery level can't be determined Created 6 years, 6 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 | build/android/provision_devices.py » ('j') | 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 boolean indicating whether or not device can be used for testing. 45 boolean indicating whether or not device can be used for testing.
46 """ 46 """
47 47
48 device_adb = device_utils.DeviceUtils(serial) 48 device_adb = device_utils.DeviceUtils(serial)
49 device_type = device_adb.old_interface.GetBuildProduct() 49 device_type = device_adb.old_interface.GetBuildProduct()
50 device_build = device_adb.old_interface.GetBuildId() 50 device_build = device_adb.old_interface.GetBuildId()
51 device_build_type = device_adb.old_interface.GetBuildType() 51 device_build_type = device_adb.old_interface.GetBuildType()
52 device_product_name = device_adb.old_interface.GetProductName() 52 device_product_name = device_adb.old_interface.GetProductName()
53 53
54 try: 54 try:
55 battery = device_adb.old_interface.GetBatteryInfo() 55 battery_info = device_adb.old_interface.GetBatteryInfo()
56 except Exception as e: 56 except Exception as e:
57 battery = None 57 battery_info = {}
58 logging.error('Unable to obtain battery info for %s, %s', serial, e) 58 logging.error('Unable to obtain battery info for %s, %s', serial, e)
59 59
60 def _GetData(re_expression, line, lambda_function=lambda x:x): 60 def _GetData(re_expression, line, lambda_function=lambda x:x):
61 if not line: 61 if not line:
62 return 'Unknown' 62 return 'Unknown'
63 found = re.findall(re_expression, line) 63 found = re.findall(re_expression, line)
64 if found and len(found): 64 if found and len(found):
65 return lambda_function(found[0]) 65 return lambda_function(found[0])
66 return 'Unknown' 66 return 'Unknown'
67 67
68 def _GetBatteryInfo(battery): 68 battery_level = int(battery_info.get('level', 100))
69 if not battery:
70 return 'No battery info.'
71 battery_info = battery.split('\n')
72 return battery_info[0] + '\n '.join(battery_info[1:])
73
74 ac_power = _GetData('AC powered: (\w+)', battery)
75 battery_level = _GetData('level: (\d+)', battery)
76 imei_slice = _GetData('Device ID = (\d+)', 69 imei_slice = _GetData('Device ID = (\d+)',
77 device_adb.old_interface.GetSubscriberInfo(), 70 device_adb.old_interface.GetSubscriberInfo(),
78 lambda x: x[-6:]) 71 lambda x: x[-6:])
79 report = ['Device %s (%s)' % (serial, device_type), 72 report = ['Device %s (%s)' % (serial, device_type),
80 ' Build: %s (%s)' % 73 ' Build: %s (%s)' %
81 (device_build, device_adb.old_interface.GetBuildFingerprint()), 74 (device_build, device_adb.old_interface.GetBuildFingerprint()),
82 ' %s' % _GetBatteryInfo(battery), 75 ' Current Battery Service state: ',
76 '\n'.join([' %s: %s' % (k, v)
77 for k, v in battery_info.iteritems()]),
83 ' IMEI slice: %s' % imei_slice, 78 ' IMEI slice: %s' % imei_slice,
84 ' Wifi IP: %s' % device_adb.old_interface.GetWifiIP(), 79 ' Wifi IP: %s' % device_adb.old_interface.GetWifiIP(),
85 ''] 80 '']
86 81
87 errors = [] 82 errors = []
88 if battery_level < 15: 83 if battery_level < 15:
89 errors += ['Device critically low in battery. Turning off device.'] 84 errors += ['Device critically low in battery. Turning off device.']
90 if not options.no_provisioning_check: 85 if not options.no_provisioning_check:
91 setup_wizard_disabled = ( 86 setup_wizard_disabled = (
92 device_adb.old_interface.GetSetupWizardStatus() == 'DISABLED') 87 device_adb.old_interface.GetSetupWizardStatus() == 'DISABLED')
93 if not setup_wizard_disabled and device_build_type != 'user': 88 if not setup_wizard_disabled and device_build_type != 'user':
94 errors += ['Setup wizard not disabled. Was it provisioned correctly?'] 89 errors += ['Setup wizard not disabled. Was it provisioned correctly?']
95 if device_product_name == 'mantaray' and ac_power != 'true': 90 if (device_product_name == 'mantaray' and
91 battery_info.get('AC powered', None) != 'true'):
96 errors += ['Mantaray device not connected to AC power.'] 92 errors += ['Mantaray device not connected to AC power.']
97 93
98 # Turn off devices with low battery. 94 # Turn off devices with low battery.
99 if battery_level < 15: 95 if battery_level < 15:
100 try: 96 try:
101 device_adb.EnableRoot() 97 device_adb.EnableRoot()
102 except device_errors.CommandFailedError as e: 98 except device_errors.CommandFailedError as e:
103 # Attempt shutdown anyway. 99 # Attempt shutdown anyway.
104 # TODO(jbudorick) Handle this exception appropriately after interface 100 # TODO(jbudorick) Handle this exception appropriately after interface
105 # conversions are finished. 101 # conversions are finished.
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 # devices with critically low battery. Remove those devices from testing, 338 # devices with critically low battery. Remove those devices from testing,
343 # allowing build to continue with good devices. 339 # allowing build to continue with good devices.
344 return 2 340 return 2
345 341
346 if not devices: 342 if not devices:
347 return 1 343 return 1
348 344
349 345
350 if __name__ == '__main__': 346 if __name__ == '__main__':
351 sys.exit(main()) 347 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | build/android/provision_devices.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698