| 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 recover devices in a known bad state.""" | 6 """A script to recover devices in a known bad state.""" |
| 7 | 7 |
| 8 import argparse | 8 import argparse |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 parser.add_argument('--blacklist-file', help='Device blacklist JSON file.') | 161 parser.add_argument('--blacklist-file', help='Device blacklist JSON file.') |
| 162 parser.add_argument('--known-devices-file', action='append', default=[], | 162 parser.add_argument('--known-devices-file', action='append', default=[], |
| 163 dest='known_devices_files', | 163 dest='known_devices_files', |
| 164 help='Path to known device lists.') | 164 help='Path to known device lists.') |
| 165 parser.add_argument('-v', '--verbose', action='count', default=1, | 165 parser.add_argument('-v', '--verbose', action='count', default=1, |
| 166 help='Log more information.') | 166 help='Log more information.') |
| 167 | 167 |
| 168 args = parser.parse_args() | 168 args = parser.parse_args() |
| 169 run_tests_helper.SetLogLevel(args.verbose) | 169 run_tests_helper.SetLogLevel(args.verbose) |
| 170 | 170 |
| 171 devil_custom_deps = None | 171 devil_dynamic_config = { |
| 172 'config_type': 'BaseConfig', |
| 173 'dependencies': {}, |
| 174 } |
| 175 |
| 172 if args.adb_path: | 176 if args.adb_path: |
| 173 devil_custom_deps = { | 177 devil_dynamic_config['dependencies'].update({ |
| 174 'adb': { | 178 'adb': { |
| 175 devil_env.GetPlatform(): [args.adb_path], | 179 'file_info': { |
| 176 }, | 180 devil_env.GetPlatform(): { |
| 177 } | 181 'local_paths': [args.adb_path] |
| 178 devil_env.config.Initialize(configs=devil_custom_deps) | 182 } |
| 183 } |
| 184 } |
| 185 }) |
| 186 devil_env.config.Initialize(configs=[devil_dynamic_config]) |
| 179 | 187 |
| 180 blacklist = (device_blacklist.Blacklist(args.blacklist_file) | 188 blacklist = (device_blacklist.Blacklist(args.blacklist_file) |
| 181 if args.blacklist_file | 189 if args.blacklist_file |
| 182 else None) | 190 else None) |
| 183 | 191 |
| 184 expected_devices = device_status.GetExpectedDevices(args.known_devices_files) | 192 expected_devices = device_status.GetExpectedDevices(args.known_devices_files) |
| 185 usb_devices = set(lsusb.get_android_devices()) | 193 usb_devices = set(lsusb.get_android_devices()) |
| 186 devices = [device_utils.DeviceUtils(s) | 194 devices = [device_utils.DeviceUtils(s) |
| 187 for s in expected_devices.union(usb_devices)] | 195 for s in expected_devices.union(usb_devices)] |
| 188 | 196 |
| 189 RecoverDevices(devices, blacklist) | 197 RecoverDevices(devices, blacklist) |
| 190 | 198 |
| 191 | 199 |
| 192 if __name__ == '__main__': | 200 if __name__ == '__main__': |
| 193 sys.exit(main()) | 201 sys.exit(main()) |
| OLD | NEW |