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 json | 8 import json |
9 import logging | 9 import logging |
10 import optparse | 10 import optparse |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 Args: | 45 Args: |
46 serial: The serial of the attached device to construct info about. | 46 serial: The serial of the attached device to construct info about. |
47 | 47 |
48 Returns: | 48 Returns: |
49 Tuple of device type, build id, report as a string, error messages, and | 49 Tuple of device type, build id, report as a string, error messages, and |
50 boolean indicating whether or not device can be used for testing. | 50 boolean indicating whether or not device can be used for testing. |
51 """ | 51 """ |
52 device = device_utils.DeviceUtils(serial) | 52 device = device_utils.DeviceUtils(serial) |
53 battery = battery_utils.BatteryUtils(device) | 53 battery = battery_utils.BatteryUtils(device) |
54 | 54 |
55 battery_info = {} | 55 build_product = '' |
| 56 build_id = '' |
56 battery_level = 100 | 57 battery_level = 100 |
57 errors = [] | 58 errors = [] |
58 dev_good = True | 59 dev_good = True |
59 json_data = { | 60 json_data = {} |
60 'serial': serial, | |
61 'type': device.build_product, | |
62 'build': device.build_id, | |
63 'build_detail': device.GetProp('ro.build.fingerprint'), | |
64 'battery': {}, | |
65 'imei_slice': 'Unknown', | |
66 'wifi_ip': device.GetProp('dhcp.wlan0.ipaddress'), | |
67 } | |
68 | 61 |
69 try: | 62 try: |
| 63 build_product = device.build_product |
| 64 build_id = device.build_id |
| 65 |
| 66 json_data = { |
| 67 'serial': serial, |
| 68 'type': build_product, |
| 69 'build': build_id, |
| 70 'build_detail': device.GetProp('ro.build.fingerprint'), |
| 71 'battery': {}, |
| 72 'imei_slice': 'Unknown', |
| 73 'wifi_ip': device.GetProp('dhcp.wlan0.ipaddress'), |
| 74 } |
| 75 |
| 76 battery_info = {} |
70 try: | 77 try: |
71 battery_info = battery.GetBatteryInfo(timeout=5) | 78 battery_info = battery.GetBatteryInfo(timeout=5) |
72 battery_level = int(battery_info.get('level', battery_level)) | 79 battery_level = int(battery_info.get('level', battery_level)) |
73 json_data['battery'] = battery_info | 80 json_data['battery'] = battery_info |
74 except device_errors.CommandFailedError: | 81 except device_errors.CommandFailedError: |
75 logging.exception('Failed to get battery information for %s', serial) | 82 logging.exception('Failed to get battery information for %s', serial) |
76 | 83 |
77 try: | 84 try: |
78 for l in device.RunShellCommand(['dumpsys', 'iphonesubinfo'], | 85 for l in device.RunShellCommand(['dumpsys', 'iphonesubinfo'], |
79 check_return=True, timeout=5): | 86 check_return=True, timeout=5): |
(...skipping 16 matching lines...) Expand all Loading... |
96 if (device.product_name == 'mantaray' and | 103 if (device.product_name == 'mantaray' and |
97 battery_info.get('AC powered', None) != 'true'): | 104 battery_info.get('AC powered', None) != 'true'): |
98 errors += ['Mantaray device not connected to AC power.'] | 105 errors += ['Mantaray device not connected to AC power.'] |
99 except device_errors.CommandFailedError: | 106 except device_errors.CommandFailedError: |
100 logging.exception('Failure while getting device status.') | 107 logging.exception('Failure while getting device status.') |
101 dev_good = False | 108 dev_good = False |
102 except device_errors.CommandTimeoutError: | 109 except device_errors.CommandTimeoutError: |
103 logging.exception('Timeout while getting device status.') | 110 logging.exception('Timeout while getting device status.') |
104 dev_good = False | 111 dev_good = False |
105 | 112 |
106 return (device.build_product, device.build_id, battery_level, errors, | 113 return (build_product, build_id, battery_level, errors, dev_good, json_data) |
107 dev_good, json_data) | |
108 | 114 |
109 | 115 |
110 def CheckForMissingDevices(options, adb_online_devs): | 116 def CheckForMissingDevices(options, adb_online_devs): |
111 """Uses file of previous online devices to detect broken phones. | 117 """Uses file of previous online devices to detect broken phones. |
112 | 118 |
113 Args: | 119 Args: |
114 options: out_dir parameter of options argument is used as the base | 120 options: out_dir parameter of options argument is used as the base |
115 directory to load and update the cache file. | 121 directory to load and update the cache file. |
116 adb_online_devs: A list of serial numbers of the currently visible | 122 adb_online_devs: A list of serial numbers of the currently visible |
117 and online attached devices. | 123 and online attached devices. |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 | 409 |
404 if num_failed_devs == len(devices): | 410 if num_failed_devs == len(devices): |
405 return 2 | 411 return 2 |
406 | 412 |
407 if not devices: | 413 if not devices: |
408 return 1 | 414 return 1 |
409 | 415 |
410 | 416 |
411 if __name__ == '__main__': | 417 if __name__ == '__main__': |
412 sys.exit(main()) | 418 sys.exit(main()) |
OLD | NEW |