OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 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 """Installs an APK. | 7 """Installs an APK. |
8 | 8 |
9 """ | 9 """ |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 """Records the metadata from the device for apk_package.""" | 49 """Records the metadata from the device for apk_package.""" |
50 metadata = GetMetadata(apk_package) | 50 metadata = GetMetadata(apk_package) |
51 if not metadata: | 51 if not metadata: |
52 raise 'APK install failed unexpectedly.' | 52 raise 'APK install failed unexpectedly.' |
53 | 53 |
54 with open(metadata_path, 'w') as outfile: | 54 with open(metadata_path, 'w') as outfile: |
55 outfile.write(metadata) | 55 outfile.write(metadata) |
56 | 56 |
57 | 57 |
58 def main(argv): | 58 def main(argv): |
| 59 if not build_utils.IsDeviceReady(): |
| 60 build_utils.PrintBigWarning( |
| 61 'Zero (or multiple) devices attached. Skipping APK install.') |
| 62 return |
| 63 |
59 parser = optparse.OptionParser() | 64 parser = optparse.OptionParser() |
60 parser.add_option('--android-sdk-tools', | 65 parser.add_option('--android-sdk-tools', |
61 help='Path to Android SDK tools.') | 66 help='Path to Android SDK tools.') |
62 parser.add_option('--apk-path', | 67 parser.add_option('--apk-path', |
63 help='Path to .apk to install.') | 68 help='Path to .apk to install.') |
64 parser.add_option('--install-record', | 69 parser.add_option('--install-record', |
65 help='Path to install record (touched only when APK is installed).') | 70 help='Path to install record (touched only when APK is installed).') |
66 parser.add_option('--stamp', | 71 parser.add_option('--stamp', |
67 help='Path to touch on success.') | 72 help='Path to touch on success.') |
68 options, _ = parser.parse_args() | 73 options, _ = parser.parse_args() |
(...skipping 26 matching lines...) Expand all Loading... |
95 input_paths=[options.apk_path], | 100 input_paths=[options.apk_path], |
96 input_strings=install_cmd, | 101 input_strings=install_cmd, |
97 force=force_install) | 102 force=force_install) |
98 | 103 |
99 if options.stamp: | 104 if options.stamp: |
100 build_utils.Touch(options.stamp) | 105 build_utils.Touch(options.stamp) |
101 | 106 |
102 | 107 |
103 if __name__ == '__main__': | 108 if __name__ == '__main__': |
104 sys.exit(main(sys.argv)) | 109 sys.exit(main(sys.argv)) |
OLD | NEW |