OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 def main(): | 155 def main(): |
156 parser = optparse.OptionParser() | 156 parser = optparse.OptionParser() |
157 parser.add_option('', '--out-dir', | 157 parser.add_option('', '--out-dir', |
158 help='Directory where the device path is stored', | 158 help='Directory where the device path is stored', |
159 default=os.path.join(os.path.dirname(__file__), '..', | 159 default=os.path.join(os.path.dirname(__file__), '..', |
160 '..', 'out')) | 160 '..', 'out')) |
161 | 161 |
162 options, args = parser.parse_args() | 162 options, args = parser.parse_args() |
163 if args: | 163 if args: |
164 parser.error('Unknown options %s' % args) | 164 parser.error('Unknown options %s' % args) |
165 buildbot_report.PrintNamedStep('Device Status Check') | |
166 devices = android_commands.GetAttachedDevices() | 165 devices = android_commands.GetAttachedDevices() |
167 types, builds, reports, errors = [], [], [], [] | 166 types, builds, reports, errors = [], [], [], [] |
168 if devices: | 167 if devices: |
169 types, builds, reports, errors = zip(*[DeviceInfo(dev) for dev in devices]) | 168 types, builds, reports, errors = zip(*[DeviceInfo(dev) for dev in devices]) |
170 | 169 |
171 unique_types = list(set(types)) | 170 unique_types = list(set(types)) |
172 unique_builds = list(set(builds)) | 171 unique_builds = list(set(builds)) |
173 | 172 |
174 buildbot_report.PrintMsg('Online devices: %d. Device types %s, builds %s' | 173 buildbot_report.PrintMsg('Online devices: %d. Device types %s, builds %s' |
175 % (len(devices), unique_types, unique_builds)) | 174 % (len(devices), unique_types, unique_builds)) |
176 print '\n'.join(reports) | 175 print '\n'.join(reports) |
177 | 176 |
178 full_errors = [] | 177 full_errors = [] |
179 for serial, device_errors in zip(devices, errors): | 178 for serial, device_errors in zip(devices, errors): |
180 full_errors.extend('%s: %s' % (serial, error) for error in device_errors) | 179 full_errors.extend('%s: %s' % (serial, error) for error in device_errors) |
181 if full_errors: | 180 if full_errors: |
182 buildbot_report.PrintWarning() | 181 buildbot_report.PrintWarning() |
183 print '\n'.join(full_errors) | 182 print '\n'.join(full_errors) |
184 | 183 |
185 CheckForMissingDevices(options, devices) | 184 CheckForMissingDevices(options, devices) |
186 | 185 |
187 if __name__ == '__main__': | 186 if __name__ == '__main__': |
188 sys.exit(main()) | 187 sys.exit(main()) |
OLD | NEW |