OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 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 """Provisions Android devices with settings required for bots. | 7 """Provisions Android devices with settings required for bots. |
8 | 8 |
9 Usage: | 9 Usage: |
10 ./provision_devices.py [-d <device serial number>] | 10 ./provision_devices.py [-d <device serial number>] |
11 """ | 11 """ |
12 | 12 |
13 import argparse | 13 import argparse |
14 import datetime | 14 import datetime |
15 import json | 15 import json |
16 import logging | 16 import logging |
17 import os | 17 import os |
18 import posixpath | 18 import posixpath |
19 import re | 19 import re |
20 import subprocess | 20 import subprocess |
21 import sys | 21 import sys |
22 import time | 22 import time |
23 | 23 |
24 # Import _strptime before threaded code. datetime.datetime.strptime is | 24 # Import _strptime before threaded code. datetime.datetime.strptime is |
25 # threadsafe except for the initial import of the _strptime module. | 25 # threadsafe except for the initial import of the _strptime module. |
26 # See crbug.com/584730 and https://bugs.python.org/issue7980. | 26 # See crbug.com/584730 and https://bugs.python.org/issue7980. |
27 import _strptime # pylint: disable=unused-import | 27 import _strptime # pylint: disable=unused-import |
28 | 28 |
29 import devil_chromium | 29 import devil_chromium |
30 from devil import devil_env | |
31 from devil.android import battery_utils | 30 from devil.android import battery_utils |
32 from devil.android import device_blacklist | 31 from devil.android import device_blacklist |
33 from devil.android import device_errors | 32 from devil.android import device_errors |
34 from devil.android import device_temp_file | 33 from devil.android import device_temp_file |
35 from devil.android import device_utils | 34 from devil.android import device_utils |
36 from devil.android.sdk import keyevent | 35 from devil.android.sdk import keyevent |
37 from devil.android.sdk import version_codes | 36 from devil.android.sdk import version_codes |
38 from devil.constants import exit_codes | 37 from devil.constants import exit_codes |
39 from devil.utils import run_tests_helper | 38 from devil.utils import run_tests_helper |
40 from devil.utils import timeout_retry | 39 from devil.utils import timeout_retry |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 help='Json file to output the device blacklist.') | 537 help='Json file to output the device blacklist.') |
539 parser.add_argument('--chrome-specific-wipe', action='store_true', | 538 parser.add_argument('--chrome-specific-wipe', action='store_true', |
540 help='only wipe chrome specific data during provisioning') | 539 help='only wipe chrome specific data during provisioning') |
541 parser.add_argument('--emulators', action='store_true', | 540 parser.add_argument('--emulators', action='store_true', |
542 help='provision only emulators and ignore usb devices') | 541 help='provision only emulators and ignore usb devices') |
543 args = parser.parse_args() | 542 args = parser.parse_args() |
544 constants.SetBuildType(args.target) | 543 constants.SetBuildType(args.target) |
545 | 544 |
546 run_tests_helper.SetLogLevel(args.verbose) | 545 run_tests_helper.SetLogLevel(args.verbose) |
547 | 546 |
548 devil_custom_deps = None | 547 devil_chromium.Initialize(adb_path=args.adb_path) |
549 if args.adb_path: | |
550 devil_custom_deps = { | |
551 'adb': { | |
552 devil_env.GetPlatform(): [args.adb_path], | |
553 }, | |
554 } | |
555 | |
556 devil_chromium.Initialize(custom_deps=devil_custom_deps) | |
557 | 548 |
558 try: | 549 try: |
559 return ProvisionDevices(args) | 550 return ProvisionDevices(args) |
560 except (device_errors.DeviceUnreachableError, device_errors.NoDevicesError): | 551 except (device_errors.DeviceUnreachableError, device_errors.NoDevicesError): |
561 return exit_codes.INFRA | 552 return exit_codes.INFRA |
562 | 553 |
563 | 554 |
564 if __name__ == '__main__': | 555 if __name__ == '__main__': |
565 sys.exit(main()) | 556 sys.exit(main()) |
OLD | NEW |