| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """A script to keep track of devices across builds and report state.""" | 6 """A script to keep track of devices across builds and report state.""" |
| 7 | 7 |
| 8 import argparse | 8 import argparse |
| 9 import json | 9 import json |
| 10 import logging | 10 import logging |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 help='If set, overwrites known devices files wiht new ' | 251 help='If set, overwrites known devices files wiht new ' |
| 252 'values.') | 252 'values.') |
| 253 | 253 |
| 254 def main(): | 254 def main(): |
| 255 parser = argparse.ArgumentParser() | 255 parser = argparse.ArgumentParser() |
| 256 AddArguments(parser) | 256 AddArguments(parser) |
| 257 args = parser.parse_args() | 257 args = parser.parse_args() |
| 258 | 258 |
| 259 run_tests_helper.SetLogLevel(args.verbose) | 259 run_tests_helper.SetLogLevel(args.verbose) |
| 260 | 260 |
| 261 devil_custom_deps = None | 261 |
| 262 devil_dynamic_config = { |
| 263 'config_type': 'BaseConfig', |
| 264 'dependencies': {}, |
| 265 } |
| 266 |
| 262 if args.adb_path: | 267 if args.adb_path: |
| 263 devil_custom_deps = { | 268 devil_dynamic_config['dependencies'].update({ |
| 264 'adb': { | 269 'adb': { |
| 265 devil_env.GetPlatform(): [args.adb_path], | 270 'file_info': { |
| 266 }, | 271 devil_env.GetPlatform(): { |
| 267 } | 272 'local_paths': [args.adb_path] |
| 268 devil_env.config.Initialize(configs=devil_custom_deps) | 273 } |
| 274 } |
| 275 } |
| 276 }) |
| 277 devil_env.config.Initialize(configs=[devil_dynamic_config]) |
| 269 | 278 |
| 270 blacklist = (device_blacklist.Blacklist(args.blacklist_file) | 279 blacklist = (device_blacklist.Blacklist(args.blacklist_file) |
| 271 if args.blacklist_file | 280 if args.blacklist_file |
| 272 else None) | 281 else None) |
| 273 | 282 |
| 274 expected_devices = GetExpectedDevices(args.known_devices_files) | 283 expected_devices = GetExpectedDevices(args.known_devices_files) |
| 275 usb_devices = set(lsusb.get_android_devices()) | 284 usb_devices = set(lsusb.get_android_devices()) |
| 276 devices = [device_utils.DeviceUtils(s) | 285 devices = [device_utils.DeviceUtils(s) |
| 277 for s in expected_devices.union(usb_devices)] | 286 for s in expected_devices.union(usb_devices)] |
| 278 | 287 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 293 # Dump the device statuses to JSON. | 302 # Dump the device statuses to JSON. |
| 294 if args.json_output: | 303 if args.json_output: |
| 295 with open(args.json_output, 'wb') as f: | 304 with open(args.json_output, 'wb') as f: |
| 296 f.write(json.dumps(statuses, indent=4)) | 305 f.write(json.dumps(statuses, indent=4)) |
| 297 | 306 |
| 298 live_devices = [status['serial'] for status in statuses | 307 live_devices = [status['serial'] for status in statuses |
| 299 if (status['adb_status'] == 'device' | 308 if (status['adb_status'] == 'device' |
| 300 and not IsBlacklisted(status['serial'], blacklist))] | 309 and not IsBlacklisted(status['serial'], blacklist))] |
| 301 | 310 |
| 302 # If all devices failed, or if there are no devices, it's an infra error. | 311 # If all devices failed, or if there are no devices, it's an infra error. |
| 312 if not live_devices: |
| 313 logging.error('No available devices.') |
| 303 return 0 if live_devices else exit_codes.INFRA | 314 return 0 if live_devices else exit_codes.INFRA |
| 304 | 315 |
| 305 | 316 |
| 306 if __name__ == '__main__': | 317 if __name__ == '__main__': |
| 307 sys.exit(main()) | 318 sys.exit(main()) |
| OLD | NEW |