Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame^] | 1 | #!/usr/bin/python2 |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2010 Google Inc. All Rights Reserved. |
cmtice | d96e457 | 2015-05-19 16:19:25 -0700 | [diff] [blame] | 4 | """Script to wrap test_that script. |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 5 | |
| 6 | This script can login to the chromeos machine using the test private key. |
| 7 | """ |
| 8 | |
Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame^] | 9 | from __future__ import print_function |
| 10 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 11 | __author__ = 'asharif@google.com (Ahmad Sharif)' |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 12 | |
Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame^] | 13 | import argparse |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 14 | import os |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 15 | import sys |
kbaclawski | 20082a0 | 2013-02-16 02:12:57 +0000 | [diff] [blame] | 16 | |
Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame^] | 17 | from cros_utils import command_executer |
| 18 | from cros_utils import misc |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 19 | |
| 20 | |
| 21 | def Usage(parser, message): |
Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame^] | 22 | print('ERROR: %s' % message) |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 23 | parser.print_help() |
| 24 | sys.exit(0) |
| 25 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 26 | |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 27 | def Main(argv): |
Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame^] | 28 | parser = argparse.ArgumentParser() |
| 29 | parser.add_argument('-c', |
| 30 | '--chromeos_root', |
| 31 | dest='chromeos_root', |
| 32 | help='ChromeOS root checkout directory') |
| 33 | parser.add_argument('-r', |
| 34 | '--remote', |
| 35 | dest='remote', |
| 36 | help='Remote chromeos device.') |
| 37 | options = parser.parse_args(argv) |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 38 | if options.chromeos_root is None: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 39 | Usage(parser, 'chromeos_root must be given') |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 40 | |
| 41 | if options.remote is None: |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 42 | Usage(parser, 'remote must be given') |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 43 | |
| 44 | options.chromeos_root = os.path.expanduser(options.chromeos_root) |
| 45 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 46 | command = 'ls -lt /' |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 47 | ce = command_executer.GetCommandExecuter() |
| 48 | ce.CrosRunCommand(command, |
| 49 | chromeos_root=options.chromeos_root, |
| 50 | machine=options.remote) |
| 51 | |
kbaclawski | 20082a0 | 2013-02-16 02:12:57 +0000 | [diff] [blame] | 52 | version_dir_path, script_name = misc.GetRoot(sys.argv[0]) |
| 53 | version_dir = misc.GetRoot(version_dir_path)[1] |
asharif | 29775b2 | 2013-02-15 05:15:38 +0000 | [diff] [blame] | 54 | |
| 55 | # Tests to copy directories and files to the chromeos box. |
| 56 | ce.CopyFiles(version_dir_path, |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 57 | '/tmp/' + version_dir, |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 58 | dest_machine=options.remote, |
| 59 | dest_cros=True, |
| 60 | chromeos_root=options.chromeos_root) |
asharif | 29775b2 | 2013-02-15 05:15:38 +0000 | [diff] [blame] | 61 | ce.CopyFiles(version_dir_path, |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 62 | '/tmp/' + version_dir + '1', |
asharif | 29775b2 | 2013-02-15 05:15:38 +0000 | [diff] [blame] | 63 | dest_machine=options.remote, |
| 64 | dest_cros=True, |
| 65 | chromeos_root=options.chromeos_root) |
| 66 | ce.CopyFiles(sys.argv[0], |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 67 | '/tmp/' + script_name, |
asharif | 29775b2 | 2013-02-15 05:15:38 +0000 | [diff] [blame] | 68 | recursive=False, |
| 69 | dest_machine=options.remote, |
| 70 | dest_cros=True, |
| 71 | chromeos_root=options.chromeos_root) |
| 72 | ce.CopyFiles(sys.argv[0], |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 73 | '/tmp/' + script_name + '1', |
asharif | 29775b2 | 2013-02-15 05:15:38 +0000 | [diff] [blame] | 74 | recursive=False, |
| 75 | dest_machine=options.remote, |
| 76 | dest_cros=True, |
| 77 | chromeos_root=options.chromeos_root) |
| 78 | |
| 79 | # Test to copy directories and files from the chromeos box. |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 80 | ce.CopyFiles('/tmp/' + script_name, |
| 81 | '/tmp/hello', |
asharif | 29775b2 | 2013-02-15 05:15:38 +0000 | [diff] [blame] | 82 | recursive=False, |
| 83 | src_machine=options.remote, |
| 84 | src_cros=True, |
| 85 | chromeos_root=options.chromeos_root) |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 86 | ce.CopyFiles('/tmp/' + script_name, |
| 87 | '/tmp/' + script_name, |
asharif | 29775b2 | 2013-02-15 05:15:38 +0000 | [diff] [blame] | 88 | recursive=False, |
| 89 | src_machine=options.remote, |
| 90 | src_cros=True, |
| 91 | chromeos_root=options.chromeos_root) |
asharif | 6f4065c | 2013-02-15 09:04:02 +0000 | [diff] [blame] | 92 | board = ce.CrosLearnBoard(options.chromeos_root, options.remote) |
Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame^] | 93 | print(board) |
asharif | 29775b2 | 2013-02-15 05:15:38 +0000 | [diff] [blame] | 94 | return 0 |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 95 | |
| 96 | |
Luis Lozano | f2a3ef4 | 2015-12-15 13:49:30 -0800 | [diff] [blame] | 97 | if __name__ == '__main__': |
Caroline Tice | 88272d4 | 2016-01-13 09:48:29 -0800 | [diff] [blame^] | 98 | Main(sys.argv[1:]) |