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 multiprocessing | 9 import multiprocessing |
10 import optparse | 10 import optparse |
11 import os | 11 import os |
12 import sys | 12 import sys |
13 | 13 |
14 from pylib import android_commands | 14 from pylib import android_commands |
15 from pylib import constants | 15 from pylib import constants |
16 from pylib.device import device_utils | 16 from pylib.device import device_utils |
17 from pylib.utils import apk_helper | 17 from pylib.utils import apk_helper |
18 from pylib.utils import test_options_parser | |
19 | 18 |
20 | 19 |
21 def AddInstallAPKOption(option_parser): | 20 def AddInstallAPKOption(option_parser): |
22 """Adds apk option used to install the APK to the OptionParser.""" | 21 """Adds apk option used to install the APK to the OptionParser.""" |
23 test_options_parser.AddBuildTypeOption(option_parser) | |
24 option_parser.add_option('--apk', | 22 option_parser.add_option('--apk', |
25 help=('The name of the apk containing the ' | 23 help=('The name of the apk containing the ' |
26 ' application (with the .apk extension).')) | 24 ' application (with the .apk extension).')) |
27 option_parser.add_option('--apk_package', | 25 option_parser.add_option('--apk_package', |
28 help=('The package name used by the apk containing ' | 26 help=('The package name used by the apk containing ' |
29 'the application.')) | 27 'the application.')) |
30 option_parser.add_option('--keep_data', | 28 option_parser.add_option('--keep_data', |
31 action='store_true', | 29 action='store_true', |
32 default=False, | 30 default=False, |
33 help=('Keep the package data when installing ' | 31 help=('Keep the package data when installing ' |
34 'the application.')) | 32 'the application.')) |
| 33 option_parser.add_option('--debug', action='store_const', const='Debug', |
| 34 dest='build_type', |
| 35 default=os.environ.get('BUILDTYPE', 'Debug'), |
| 36 help='If set, run test suites under out/Debug. ' |
| 37 'Default is env var BUILDTYPE or Debug') |
| 38 option_parser.add_option('--release', action='store_const', const='Release', |
| 39 dest='build_type', |
| 40 help='If set, run test suites under out/Release. ' |
| 41 'Default is env var BUILDTYPE or Debug.') |
35 | 42 |
36 | 43 |
37 def ValidateInstallAPKOption(option_parser, options): | 44 def ValidateInstallAPKOption(option_parser, options): |
38 """Validates the apk option and potentially qualifies the path.""" | 45 """Validates the apk option and potentially qualifies the path.""" |
39 if not options.apk: | 46 if not options.apk: |
40 option_parser.error('--apk is mandatory.') | 47 option_parser.error('--apk is mandatory.') |
41 if not os.path.exists(options.apk): | 48 if not os.path.exists(options.apk): |
42 options.apk = os.path.join(constants.GetOutDirectory(), 'apks', | 49 options.apk = os.path.join(constants.GetOutDirectory(), 'apks', |
43 options.apk) | 50 options.apk) |
44 | 51 |
(...skipping 24 matching lines...) Expand all Loading... |
69 pool = multiprocessing.Pool(len(devices)) | 76 pool = multiprocessing.Pool(len(devices)) |
70 # Send a tuple (apk_path, apk_package, device) per device. | 77 # Send a tuple (apk_path, apk_package, device) per device. |
71 pool.map(_InstallApk, zip([options.apk] * len(devices), | 78 pool.map(_InstallApk, zip([options.apk] * len(devices), |
72 [options.apk_package] * len(devices), | 79 [options.apk_package] * len(devices), |
73 [options.keep_data] * len(devices), | 80 [options.keep_data] * len(devices), |
74 devices)) | 81 devices)) |
75 | 82 |
76 | 83 |
77 if __name__ == '__main__': | 84 if __name__ == '__main__': |
78 sys.exit(main(sys.argv)) | 85 sys.exit(main(sys.argv)) |
OLD | NEW |