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 optparse | 9 import optparse |
10 import os | 10 import os |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 if len(args) > 1 and options.apk: | 66 if len(args) > 1 and options.apk: |
67 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.") |
68 elif len(args) > 2: | 68 elif len(args) > 2: |
69 parser.error("Too many arguments.") | 69 parser.error("Too many arguments.") |
70 | 70 |
71 constants.SetBuildType(options.build_type) | 71 constants.SetBuildType(options.build_type) |
72 ValidateInstallAPKOption(parser, options, args) | 72 ValidateInstallAPKOption(parser, options, args) |
73 | 73 |
74 devices = android_commands.GetAttachedDevices() | 74 devices = android_commands.GetAttachedDevices() |
75 | 75 |
| 76 if not devices: |
| 77 raise Exception('Error: no connected devices') |
| 78 |
76 if options.device: | 79 if options.device: |
77 if options.device not in devices: | 80 if options.device not in devices: |
78 raise Exception('Error: %s not in attached devices %s' % (options.device, | 81 raise Exception('Error: %s not in attached devices %s' % (options.device, |
79 ','.join(devices))) | 82 ','.join(devices))) |
80 devices = [options.device] | 83 devices = [options.device] |
81 | 84 |
82 if not devices: | |
83 raise Exception('Error: no connected devices') | |
84 | |
85 device_utils.DeviceUtils.parallel(devices).Install( | 85 device_utils.DeviceUtils.parallel(devices).Install( |
86 options.apk, reinstall=options.keep_data) | 86 options.apk, reinstall=options.keep_data) |
87 | 87 |
88 | 88 |
89 if __name__ == '__main__': | 89 if __name__ == '__main__': |
90 sys.exit(main(sys.argv)) | 90 sys.exit(main(sys.argv)) |
91 | 91 |
OLD | NEW |