Home | History | Annotate | Download | only in tools
      1 #!/usr/bin/env python
      2 # Copyright 2016 The Chromium Authors. All rights reserved.
      3 # Use of this source code is governed by a BSD-style license that can be
      4 # found in the LICENSE file.
      5 
      6 """Waits for the given devices to be available."""
      7 
      8 import argparse
      9 import os
     10 import sys
     11 
     12 if __name__ == '__main__':
     13   sys.path.append(
     14       os.path.abspath(os.path.join(os.path.dirname(__file__),
     15                                    '..', '..', '..')))
     16 
     17 from devil.android import device_utils
     18 from devil.android.tools import script_common
     19 from devil.utils import run_tests_helper
     20 
     21 
     22 def main(raw_args):
     23   parser = argparse.ArgumentParser()
     24   parser.add_argument('-v', '--verbose', action='count', help='Log more.')
     25   parser.add_argument('-t', '--timeout', default=30, type=int,
     26                       help='Seconds to wait for the devices.')
     27   parser.add_argument('--adb-path', help='ADB binary to use.')
     28   parser.add_argument('device_serials', nargs='*', metavar='SERIAL',
     29                       help='Serials of the devices to wait for.')
     30 
     31   args = parser.parse_args(raw_args)
     32 
     33   run_tests_helper.SetLogLevel(args.verbose)
     34   script_common.InitializeEnvironment(args)
     35 
     36   devices = device_utils.DeviceUtils.HealthyDevices(
     37       device_arg=args.device_serials)
     38   parallel_devices = device_utils.DeviceUtils.parallel(devices)
     39   parallel_devices.WaitUntilFullyBooted(timeout=args.timeout)
     40   return 0
     41 
     42 
     43 if __name__ == '__main__':
     44   sys.exit(main(sys.argv[1:]))
     45