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

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: Rebase to latest code 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 19 matching lines...) Expand all
30 'the application.')) 30 'the application.'))
31 option_parser.add_option('--debug', action='store_const', const='Debug', 31 option_parser.add_option('--debug', action='store_const', const='Debug',
32 dest='build_type', 32 dest='build_type',
33 default=os.environ.get('BUILDTYPE', 'Debug'), 33 default=os.environ.get('BUILDTYPE', 'Debug'),
34 help='If set, run test suites under out/Debug. ' 34 help='If set, run test suites under out/Debug. '
35 'Default is env var BUILDTYPE or Debug') 35 'Default is env var BUILDTYPE or Debug')
36 option_parser.add_option('--release', action='store_const', const='Release', 36 option_parser.add_option('--release', action='store_const', const='Release',
37 dest='build_type', 37 dest='build_type',
38 help='If set, run test suites under out/Release. ' 38 help='If set, run test suites under out/Release. '
39 'Default is env var BUILDTYPE or Debug.') 39 'Default is env var BUILDTYPE or Debug.')
40 option_parser.add_option('-d', '--device', dest='device',
41 help='Target device for apk to install on.')
40 42
41 43
42 def ValidateInstallAPKOption(option_parser, options, args): 44 def ValidateInstallAPKOption(option_parser, options, args):
43 """Validates the apk option and potentially qualifies the path.""" 45 """Validates the apk option and potentially qualifies the path."""
44 if not options.apk: 46 if not options.apk:
45 if len(args) > 1: 47 if len(args) > 1:
46 options.apk = args[1] 48 options.apk = args[1]
47 else: 49 else:
48 option_parser.error('apk target not specified.') 50 option_parser.error('apk target not specified.')
49 51
(...skipping 13 matching lines...) Expand all
63 65
64 if len(args) > 1 and options.apk: 66 if len(args) > 1 and options.apk:
65 parser.error("Appending the apk as argument can't be used with --apk.") 67 parser.error("Appending the apk as argument can't be used with --apk.")
66 elif len(args) > 2: 68 elif len(args) > 2:
67 parser.error("Too many arguments.") 69 parser.error("Too many arguments.")
68 70
69 constants.SetBuildType(options.build_type) 71 constants.SetBuildType(options.build_type)
70 ValidateInstallAPKOption(parser, options, args) 72 ValidateInstallAPKOption(parser, options, args)
71 73
72 devices = android_commands.GetAttachedDevices() 74 devices = android_commands.GetAttachedDevices()
75
76 if options.device:
77 if options.device not in devices:
78 raise Exception('Error: %s not in attached devices %s' % (options.device,
79 ','.join(devices)))
80 devices = [options.device]
81
73 if not devices: 82 if not devices:
74 raise Exception('Error: no connected devices') 83 raise Exception('Error: no connected devices')
75 84
76 device_utils.DeviceUtils.parallel(devices).Install( 85 device_utils.DeviceUtils.parallel(devices).Install(
77 options.apk, reinstall=options.keep_data) 86 options.apk, reinstall=options.keep_data)
78 87
79 88
80 if __name__ == '__main__': 89 if __name__ == '__main__':
81 sys.exit(main(sys.argv)) 90 sys.exit(main(sys.argv))
82 91
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