~pwlars/ubuntu-test-cases/krillin-recovery

« back to all changes in this revision

Viewing changes to scripts/reboot-and-wait

  • Committer: Andy Doan
  • Date: 2013-10-21 15:17:05 UTC
  • mfrom: (70.4.1 phablet-test-run)
  • Revision ID: andy.doan@canonical.com-20131021151705-s7p2p21tlvoch1lr
fixes some issues found while testing the MEGA test run.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import argparse
 
4
import logging
 
5
 
 
6
from phabletutils.device import AndroidBridge
 
7
 
 
8
 
 
9
def _get_arg_parser():
 
10
    parser = argparse.ArgumentParser(
 
11
        description='Reboot device and waits for networking to become active.')
 
12
    parser.add_argument('-s', '--serial', help='Device serial')
 
13
    parser.add_argument('-n', '--num-tries', type=int, default=3,
 
14
                        help='''How many times to retry on failure.
 
15
                             default=%(default)d''')
 
16
    return parser
 
17
 
 
18
 
 
19
def main(args):
 
20
    device = AndroidBridge(args.serial)
 
21
    for i in range(args.num_tries):
 
22
        device.reboot()
 
23
        device.wait_for_device()
 
24
        try:
 
25
            device.wait_for_network()
 
26
            return 0
 
27
        except:
 
28
            pass  # try the loop again
 
29
    logging.error('device failed to start and activate networking')
 
30
    return 1
 
31
 
 
32
 
 
33
if __name__ == '__main__':
 
34
    logging.basicConfig(level=logging.INFO)
 
35
    logging.getLogger().name = 'reboot-and-wait'
 
36
    args = _get_arg_parser().parse_args()
 
37
    exit(main(args))