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