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 argparse | 9 import argparse |
10 import glob | 10 import glob |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 for split_glob in args.splits: | 76 for split_glob in args.splits: |
77 apks = [f for f in glob.glob(split_glob) if f.endswith('.apk')] | 77 apks = [f for f in glob.glob(split_glob) if f.endswith('.apk')] |
78 if not apks: | 78 if not apks: |
79 logging.warning('No apks matched for %s.', split_glob) | 79 logging.warning('No apks matched for %s.', split_glob) |
80 for f in apks: | 80 for f in apks: |
81 helper = apk_helper.ApkHelper(f) | 81 helper = apk_helper.ApkHelper(f) |
82 if (helper.GetPackageName() == base_apk_package | 82 if (helper.GetPackageName() == base_apk_package |
83 and helper.GetSplitName()): | 83 and helper.GetSplitName()): |
84 splits.append(f) | 84 splits.append(f) |
85 | 85 |
86 if args.blacklist_file: | 86 blacklist = (device_blacklist.Blacklist(args.blacklist_file) |
87 blacklist = device_blacklist.Blacklist(args.blacklist_file) | 87 if args.blacklist_file |
88 else: | 88 else None) |
89 # TODO(jbudorick): Remove this once the bots are converted. | |
90 blacklist = device_blacklist.Blacklist(device_blacklist.BLACKLIST_JSON) | |
91 | |
92 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) | 89 devices = device_utils.DeviceUtils.HealthyDevices(blacklist) |
93 | 90 |
94 if args.device: | 91 if args.device: |
95 devices = [d for d in devices if d == args.device] | 92 devices = [d for d in devices if d == args.device] |
96 if not devices: | 93 if not devices: |
97 raise device_errors.DeviceUnreachableError(args.device) | 94 raise device_errors.DeviceUnreachableError(args.device) |
98 elif not devices: | 95 elif not devices: |
99 raise device_errors.NoDevicesError() | 96 raise device_errors.NoDevicesError() |
100 | 97 |
101 def blacklisting_install(device): | 98 def blacklisting_install(device): |
(...skipping 12 matching lines...) Expand all Loading... |
114 if blacklist: | 111 if blacklist: |
115 blacklist.Extend([str(device)]) | 112 blacklist.Extend([str(device)]) |
116 logging.warning('Blacklisting %s', str(device)) | 113 logging.warning('Blacklisting %s', str(device)) |
117 | 114 |
118 device_utils.DeviceUtils.parallel(devices).pMap(blacklisting_install) | 115 device_utils.DeviceUtils.parallel(devices).pMap(blacklisting_install) |
119 | 116 |
120 | 117 |
121 if __name__ == '__main__': | 118 if __name__ == '__main__': |
122 sys.exit(main()) | 119 sys.exit(main()) |
123 | 120 |
OLD | NEW |