| 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 """Utility script to install APKs from the command line quickly.""" | 7 """Utility script to install APKs from the command line quickly.""" |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import glob | 10 import glob |
| 11 import logging | 11 import logging |
| 12 import os | 12 import os |
| 13 import sys | 13 import sys |
| 14 | 14 |
| 15 import devil_chromium | 15 import devil_chromium |
| 16 from devil import devil_env | |
| 17 from devil.android import apk_helper | 16 from devil.android import apk_helper |
| 18 from devil.android import device_blacklist | 17 from devil.android import device_blacklist |
| 19 from devil.android import device_errors | 18 from devil.android import device_errors |
| 20 from devil.android import device_utils | 19 from devil.android import device_utils |
| 21 from devil.utils import run_tests_helper | 20 from devil.utils import run_tests_helper |
| 22 from pylib import constants | 21 from pylib import constants |
| 23 | 22 |
| 24 | 23 |
| 25 def main(): | 24 def main(): |
| 26 parser = argparse.ArgumentParser() | 25 parser = argparse.ArgumentParser() |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 parser.add_argument('--timeout', type=int, | 66 parser.add_argument('--timeout', type=int, |
| 68 default=device_utils.DeviceUtils.INSTALL_DEFAULT_TIMEOUT, | 67 default=device_utils.DeviceUtils.INSTALL_DEFAULT_TIMEOUT, |
| 69 help='Seconds to wait for APK installation. ' | 68 help='Seconds to wait for APK installation. ' |
| 70 '(default: %(default)s)') | 69 '(default: %(default)s)') |
| 71 | 70 |
| 72 args = parser.parse_args() | 71 args = parser.parse_args() |
| 73 | 72 |
| 74 run_tests_helper.SetLogLevel(args.verbose) | 73 run_tests_helper.SetLogLevel(args.verbose) |
| 75 constants.SetBuildType(args.build_type) | 74 constants.SetBuildType(args.build_type) |
| 76 | 75 |
| 77 devil_custom_deps = None | |
| 78 if args.adb_path: | |
| 79 devil_custom_deps = { | |
| 80 'adb': { | |
| 81 devil_env.GetPlatform(): [args.adb_path], | |
| 82 }, | |
| 83 } | |
| 84 | |
| 85 devil_chromium.Initialize( | 76 devil_chromium.Initialize( |
| 86 output_directory=constants.GetOutDirectory(), | 77 output_directory=constants.GetOutDirectory(), |
| 87 custom_deps=devil_custom_deps) | 78 adb_path=args.adb_path) |
| 88 | 79 |
| 89 apk = args.apk_path or args.apk_name | 80 apk = args.apk_path or args.apk_name |
| 90 if not apk.endswith('.apk'): | 81 if not apk.endswith('.apk'): |
| 91 apk += '.apk' | 82 apk += '.apk' |
| 92 if not os.path.exists(apk): | 83 if not os.path.exists(apk): |
| 93 apk = os.path.join(constants.GetOutDirectory(), 'apks', apk) | 84 apk = os.path.join(constants.GetOutDirectory(), 'apks', apk) |
| 94 if not os.path.exists(apk): | 85 if not os.path.exists(apk): |
| 95 parser.error('%s not found.' % apk) | 86 parser.error('%s not found.' % apk) |
| 96 | 87 |
| 97 if args.splits: | 88 if args.splits: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if blacklist: | 123 if blacklist: |
| 133 blacklist.Extend([str(device)], reason='install_timeout') | 124 blacklist.Extend([str(device)], reason='install_timeout') |
| 134 logging.warning('Blacklisting %s', str(device)) | 125 logging.warning('Blacklisting %s', str(device)) |
| 135 | 126 |
| 136 device_utils.DeviceUtils.parallel(devices).pMap(blacklisting_install) | 127 device_utils.DeviceUtils.parallel(devices).pMap(blacklisting_install) |
| 137 | 128 |
| 138 | 129 |
| 139 if __name__ == '__main__': | 130 if __name__ == '__main__': |
| 140 sys.exit(main()) | 131 sys.exit(main()) |
| 141 | 132 |
| OLD | NEW |