OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # |
| 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 |
| 5 # found in the LICENSE file. |
| 6 |
| 7 import multiprocessing |
| 8 import optparse |
| 9 import os |
| 10 import sys |
| 11 |
| 12 from pylib import android_commands |
| 13 from pylib import test_options_parser |
| 14 from pylib import constants |
| 15 |
| 16 |
| 17 def InstallApk(args): |
| 18 options, device = args |
| 19 apk_path = os.path.join(os.environ['CHROME_SRC'], |
| 20 'out', options.build_type, |
| 21 'apks', options.apk) |
| 22 result = android_commands.AndroidCommands(device=device).ManagedInstall( |
| 23 apk_path, False, options.apk_package) |
| 24 print '----- Installed on %s -----' % device |
| 25 print result |
| 26 |
| 27 |
| 28 def main(argv): |
| 29 parser = optparse.OptionParser() |
| 30 test_options_parser.AddBuildTypeOption(parser) |
| 31 test_options_parser.AddInstallAPKOption(parser) |
| 32 options, args = parser.parse_args(argv) |
| 33 |
| 34 if len(args) > 1: |
| 35 raise Exception('Error: Unknown argument:', args[1:]) |
| 36 |
| 37 devices = android_commands.GetAttachedDevices() |
| 38 if not devices: |
| 39 raise Exception('Error: no connected devices') |
| 40 |
| 41 pool = multiprocessing.Pool(len(devices)) |
| 42 # Send a tuple (options, device) per instance of DeploySingleDevice. |
| 43 pool.map(InstallApk, zip([options] * len(devices), devices)) |
| 44 |
| 45 |
| 46 if __name__ == '__main__': |
| 47 sys.exit(main(sys.argv)) |
OLD | NEW |