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 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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()) |
OLD | NEW |