| 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 |
| 16 |
| 15 from devil.android import apk_helper | 17 from devil.android import apk_helper |
| 16 from devil.android import device_blacklist | 18 from devil.android import device_blacklist |
| 17 from devil.android import device_errors | 19 from devil.android import device_errors |
| 18 from devil.android import device_utils | 20 from devil.android import device_utils |
| 19 from devil.utils import run_tests_helper | 21 from devil.utils import run_tests_helper |
| 20 from pylib import constants | 22 from pylib import constants |
| 21 | 23 |
| 22 | 24 |
| 23 def main(): | 25 def main(): |
| 24 parser = argparse.ArgumentParser() | 26 parser = argparse.ArgumentParser() |
| (...skipping 30 matching lines...) Expand all Loading... |
| 55 help='Target device for apk to install on.') | 57 help='Target device for apk to install on.') |
| 56 parser.add_argument('--blacklist-file', help='Device blacklist JSON file.') | 58 parser.add_argument('--blacklist-file', help='Device blacklist JSON file.') |
| 57 parser.add_argument('-v', '--verbose', action='count', | 59 parser.add_argument('-v', '--verbose', action='count', |
| 58 help='Enable verbose logging.') | 60 help='Enable verbose logging.') |
| 59 | 61 |
| 60 args = parser.parse_args() | 62 args = parser.parse_args() |
| 61 | 63 |
| 62 run_tests_helper.SetLogLevel(args.verbose) | 64 run_tests_helper.SetLogLevel(args.verbose) |
| 63 constants.SetBuildType(args.build_type) | 65 constants.SetBuildType(args.build_type) |
| 64 | 66 |
| 67 devil_chromium.Initialize(output_directory=constants.GetOutDirectory()) |
| 68 |
| 65 apk = args.apk_path or args.apk_name | 69 apk = args.apk_path or args.apk_name |
| 66 if not apk.endswith('.apk'): | 70 if not apk.endswith('.apk'): |
| 67 apk += '.apk' | 71 apk += '.apk' |
| 68 if not os.path.exists(apk): | 72 if not os.path.exists(apk): |
| 69 apk = os.path.join(constants.GetOutDirectory(), 'apks', apk) | 73 apk = os.path.join(constants.GetOutDirectory(), 'apks', apk) |
| 70 if not os.path.exists(apk): | 74 if not os.path.exists(apk): |
| 71 parser.error('%s not found.' % apk) | 75 parser.error('%s not found.' % apk) |
| 72 | 76 |
| 73 if args.splits: | 77 if args.splits: |
| 74 splits = [] | 78 splits = [] |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if blacklist: | 115 if blacklist: |
| 112 blacklist.Extend([str(device)], reason='install_timeout') | 116 blacklist.Extend([str(device)], reason='install_timeout') |
| 113 logging.warning('Blacklisting %s', str(device)) | 117 logging.warning('Blacklisting %s', str(device)) |
| 114 | 118 |
| 115 device_utils.DeviceUtils.parallel(devices).pMap(blacklisting_install) | 119 device_utils.DeviceUtils.parallel(devices).pMap(blacklisting_install) |
| 116 | 120 |
| 117 | 121 |
| 118 if __name__ == '__main__': | 122 if __name__ == '__main__': |
| 119 sys.exit(main()) | 123 sys.exit(main()) |
| 120 | 124 |
| OLD | NEW |