1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3# 4# Copyright 2020 The Chromium OS Authors. All rights reserved. 5# Use of this source code is governed by a BSD-style license that can be 6# found in the LICENSE file. 7 8"""Script to wrap test_that script. 9 10This script can login to the chromeos machine using the test private key. 11""" 12 13from __future__ import print_function 14 15__author__ = 'asharif@google.com (Ahmad Sharif)' 16 17import argparse 18import os 19import sys 20 21from cros_utils import command_executer 22from cros_utils import misc 23 24 25def Usage(parser, message): 26 print('ERROR: %s' % message) 27 parser.print_help() 28 sys.exit(0) 29 30 31def Main(argv): 32 parser = argparse.ArgumentParser() 33 parser.add_argument( 34 '-c', 35 '--chromeos_root', 36 dest='chromeos_root', 37 help='ChromeOS root checkout directory') 38 parser.add_argument( 39 '-r', '--remote', dest='remote', help='Remote chromeos device.') 40 options = parser.parse_args(argv) 41 if options.chromeos_root is None: 42 Usage(parser, 'chromeos_root must be given') 43 44 if options.remote is None: 45 Usage(parser, 'remote must be given') 46 47 options.chromeos_root = os.path.expanduser(options.chromeos_root) 48 49 command = 'ls -lt /' 50 ce = command_executer.GetCommandExecuter() 51 ce.CrosRunCommand( 52 command, chromeos_root=options.chromeos_root, machine=options.remote) 53 54 version_dir_path, script_name = misc.GetRoot(sys.argv[0]) 55 version_dir = misc.GetRoot(version_dir_path)[1] 56 57 # Tests to copy directories and files to the chromeos box. 58 ce.CopyFiles( 59 version_dir_path, 60 '/tmp/' + version_dir, 61 dest_machine=options.remote, 62 dest_cros=True, 63 chromeos_root=options.chromeos_root) 64 ce.CopyFiles( 65 version_dir_path, 66 '/tmp/' + version_dir + '1', 67 dest_machine=options.remote, 68 dest_cros=True, 69 chromeos_root=options.chromeos_root) 70 ce.CopyFiles( 71 sys.argv[0], 72 '/tmp/' + script_name, 73 recursive=False, 74 dest_machine=options.remote, 75 dest_cros=True, 76 chromeos_root=options.chromeos_root) 77 ce.CopyFiles( 78 sys.argv[0], 79 '/tmp/' + script_name + '1', 80 recursive=False, 81 dest_machine=options.remote, 82 dest_cros=True, 83 chromeos_root=options.chromeos_root) 84 85 # Test to copy directories and files from the chromeos box. 86 ce.CopyFiles( 87 '/tmp/' + script_name, 88 '/tmp/hello', 89 recursive=False, 90 src_machine=options.remote, 91 src_cros=True, 92 chromeos_root=options.chromeos_root) 93 ce.CopyFiles( 94 '/tmp/' + script_name, 95 '/tmp/' + script_name, 96 recursive=False, 97 src_machine=options.remote, 98 src_cros=True, 99 chromeos_root=options.chromeos_root) 100 board = ce.CrosLearnBoard(options.chromeos_root, options.remote) 101 print(board) 102 return 0 103 104 105if __name__ == '__main__': 106 Main(sys.argv[1:]) 107