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 |
kbaclawski | 20082a0 | 2013-02-16 02:12:57 +0000 | [diff] [blame^] | 16 | |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 17 | from utils import command_executer |
kbaclawski | 20082a0 | 2013-02-16 02:12:57 +0000 | [diff] [blame^] | 18 | from utils import misc |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 19 | |
| 20 | |
| 21 | def Usage(parser, message): |
| 22 | print "ERROR: " + message |
| 23 | parser.print_help() |
| 24 | sys.exit(0) |
| 25 | |
| 26 | def Main(argv): |
| 27 | parser = optparse.OptionParser() |
| 28 | parser.add_option("-c", "--chromeos_root", dest="chromeos_root", |
| 29 | help="ChromeOS root checkout directory") |
| 30 | parser.add_option("-r", "--remote", dest="remote", |
| 31 | help="Remote chromeos device.") |
| 32 | options = parser.parse_args(argv)[0] |
| 33 | if options.chromeos_root is None: |
| 34 | Usage(parser, "chromeos_root must be given") |
| 35 | |
| 36 | if options.remote is None: |
| 37 | Usage(parser, "remote must be given") |
| 38 | |
| 39 | options.chromeos_root = os.path.expanduser(options.chromeos_root) |
| 40 | |
| 41 | command = "ls -lt /" |
| 42 | ce = command_executer.GetCommandExecuter() |
| 43 | ce.CrosRunCommand(command, |
| 44 | chromeos_root=options.chromeos_root, |
| 45 | machine=options.remote) |
| 46 | |
kbaclawski | 20082a0 | 2013-02-16 02:12:57 +0000 | [diff] [blame^] | 47 | version_dir_path, script_name = misc.GetRoot(sys.argv[0]) |
| 48 | version_dir = misc.GetRoot(version_dir_path)[1] |
asharif | 29775b2 | 2013-02-15 05:15:38 +0000 | [diff] [blame] | 49 | |
| 50 | # Tests to copy directories and files to the chromeos box. |
| 51 | ce.CopyFiles(version_dir_path, |
| 52 | "/tmp/" + version_dir, |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 53 | dest_machine=options.remote, |
| 54 | dest_cros=True, |
| 55 | chromeos_root=options.chromeos_root) |
asharif | 29775b2 | 2013-02-15 05:15:38 +0000 | [diff] [blame] | 56 | ce.CopyFiles(version_dir_path, |
| 57 | "/tmp/" + version_dir + "1", |
| 58 | dest_machine=options.remote, |
| 59 | dest_cros=True, |
| 60 | chromeos_root=options.chromeos_root) |
| 61 | ce.CopyFiles(sys.argv[0], |
| 62 | "/tmp/" + script_name, |
| 63 | recursive=False, |
| 64 | dest_machine=options.remote, |
| 65 | dest_cros=True, |
| 66 | chromeos_root=options.chromeos_root) |
| 67 | ce.CopyFiles(sys.argv[0], |
| 68 | "/tmp/" + script_name + "1", |
| 69 | recursive=False, |
| 70 | dest_machine=options.remote, |
| 71 | dest_cros=True, |
| 72 | chromeos_root=options.chromeos_root) |
| 73 | |
| 74 | # Test to copy directories and files from the chromeos box. |
| 75 | ce.CopyFiles("/tmp/" + script_name, |
| 76 | "/tmp/hello", |
| 77 | recursive=False, |
| 78 | src_machine=options.remote, |
| 79 | src_cros=True, |
| 80 | chromeos_root=options.chromeos_root) |
| 81 | ce.CopyFiles("/tmp/" + script_name, |
| 82 | "/tmp/" + script_name, |
| 83 | recursive=False, |
| 84 | src_machine=options.remote, |
| 85 | src_cros=True, |
| 86 | chromeos_root=options.chromeos_root) |
asharif | 6f4065c | 2013-02-15 09:04:02 +0000 | [diff] [blame] | 87 | board = ce.CrosLearnBoard(options.chromeos_root, options.remote) |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 88 | print board |
asharif | 29775b2 | 2013-02-15 05:15:38 +0000 | [diff] [blame] | 89 | return 0 |
asharif | bb91850 | 2013-02-15 05:15:01 +0000 | [diff] [blame] | 90 | |
| 91 | |
| 92 | if __name__ == "__main__": |
| 93 | Main(sys.argv) |