Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1171)

Side by Side Diff: build/android/adb_install_apk.py

Issue 321403002: Add option device in install apk script (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update according to comment Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 optparse 9 import optparse
10 import os 10 import os
(...skipping 20 matching lines...) Expand all
31 'the application.')) 31 'the application.'))
32 option_parser.add_option('--debug', action='store_const', const='Debug', 32 option_parser.add_option('--debug', action='store_const', const='Debug',
33 dest='build_type', 33 dest='build_type',
34 default=os.environ.get('BUILDTYPE', 'Debug'), 34 default=os.environ.get('BUILDTYPE', 'Debug'),
35 help='If set, run test suites under out/Debug. ' 35 help='If set, run test suites under out/Debug. '
36 'Default is env var BUILDTYPE or Debug') 36 'Default is env var BUILDTYPE or Debug')
37 option_parser.add_option('--release', action='store_const', const='Release', 37 option_parser.add_option('--release', action='store_const', const='Release',
38 dest='build_type', 38 dest='build_type',
39 help='If set, run test suites under out/Release. ' 39 help='If set, run test suites under out/Release. '
40 'Default is env var BUILDTYPE or Debug.') 40 'Default is env var BUILDTYPE or Debug.')
41 option_parser.add_option('-d', '--device', dest='device',
42 help=('Target device for apk to install on.'))
frankf 2014/06/12 17:25:47 no () required.
41 43
42 44
43 def ValidateInstallAPKOption(option_parser, options): 45 def ValidateInstallAPKOption(option_parser, options):
44 """Validates the apk option and potentially qualifies the path.""" 46 """Validates the apk option and potentially qualifies the path."""
45 if not options.apk: 47 if not options.apk:
46 option_parser.error('--apk is mandatory.') 48 option_parser.error('--apk is mandatory.')
47 if not os.path.exists(options.apk): 49 if not os.path.exists(options.apk):
48 options.apk = os.path.join(constants.GetOutDirectory(), 'apks', 50 options.apk = os.path.join(constants.GetOutDirectory(), 'apks',
49 options.apk) 51 options.apk)
50 52
51 53
52 def main(argv): 54 def main(argv):
53 parser = optparse.OptionParser() 55 parser = optparse.OptionParser()
54 AddInstallAPKOption(parser) 56 AddInstallAPKOption(parser)
55 options, args = parser.parse_args(argv) 57 options, args = parser.parse_args(argv)
56 constants.SetBuildType(options.build_type) 58 constants.SetBuildType(options.build_type)
57 ValidateInstallAPKOption(parser, options) 59 ValidateInstallAPKOption(parser, options)
58 if len(args) > 1: 60 if len(args) > 1:
59 raise Exception('Error: Unknown argument:', args[1:]) 61 raise Exception('Error: Unknown argument:', args[1:])
60 62
61 devices = android_commands.GetAttachedDevices() 63 devices = android_commands.GetAttachedDevices()
64
65 if options.device:
66 if options.device not in devices:
67 raise Exception('Error: %s not in attached devices %s' % (options.device,
68 ','.join(devices)))
69 devices = [options.device]
70
62 if not devices: 71 if not devices:
63 raise Exception('Error: no connected devices') 72 raise Exception('Error: no connected devices')
64 73
65 if not options.apk_package: 74 if not options.apk_package:
66 options.apk_package = apk_helper.GetPackageName(options.apk) 75 options.apk_package = apk_helper.GetPackageName(options.apk)
67 76
68 device_utils.DeviceUtils.parallel(devices).old_interface.ManagedInstall( 77 device_utils.DeviceUtils.parallel(devices).old_interface.ManagedInstall(
69 options.apk, options.keep_data, options.apk_package).pFinish(None) 78 options.apk, options.keep_data, options.apk_package).pFinish(None)
70 79
71 80
72 if __name__ == '__main__': 81 if __name__ == '__main__':
73 sys.exit(main(sys.argv)) 82 sys.exit(main(sys.argv))
74 83
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698