diff options
author | Caroline Tice <cmtice@google.com> | 2017-04-06 17:16:05 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-04-08 19:40:20 -0700 |
commit | f6ef4395fe1896ba68c80e52cb24763b0fcfe7f8 (patch) | |
tree | 7612123711db98f0746e56b66368d16b388192bd /tc_enter_chroot.py | |
parent | 8c18be1425c8a4ecfc059a7c637fc93f33edab1f (diff) | |
download | toolchain-utils-f6ef4395fe1896ba68c80e52cb24763b0fcfe7f8.tar.gz |
[toolchain-utils] Fix remaining lint errors in toolchain-utils.
In addition to fixing the lint errors, this also fixes the Python
formatting issues (ran tc_pyformat on nearly all the files).
BUG=chromium:570450
TEST=Ran all crosperf & bisect tool unit tests.
Ran afe_lock_machine.py (check machine status)
Ran full crosperf test (octane, speedometer, BootPerf) on alex.
Change-Id: Ic86f9192801ac67769f3de30f1c5f0d203ce0831
Reviewed-on: https://chromium-review.googlesource.com/471886
Commit-Ready: Caroline Tice <cmtice@chromium.org>
Tested-by: Caroline Tice <cmtice@chromium.org>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Diffstat (limited to 'tc_enter_chroot.py')
-rwxr-xr-x | tc_enter_chroot.py | 116 |
1 files changed, 62 insertions, 54 deletions
diff --git a/tc_enter_chroot.py b/tc_enter_chroot.py index 573e5585..d919c96d 100755 --- a/tc_enter_chroot.py +++ b/tc_enter_chroot.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/bin/env python2 # # Copyright 2010 Google Inc. All Rights Reserved. """Script to enter the ChromeOS chroot with mounted sources. @@ -86,41 +86,47 @@ def Main(argv, return_output=False): """The main function.""" parser = argparse.ArgumentParser() - parser.add_argument('-c', - '--chromeos_root', - dest='chromeos_root', - default='../..', - help='ChromeOS root checkout directory.') - parser.add_argument('-t', - '--toolchain_root', - dest='toolchain_root', - help='Toolchain root directory.') - parser.add_argument('-o', - '--output', - dest='output', - help='Toolchain output directory') - parser.add_argument('--sudo', - dest='sudo', - action='store_true', - default=False, - help='Run the command with sudo.') - parser.add_argument('-r', - '--third_party', - dest='third_party', - help='The third_party directory to mount.') - parser.add_argument('-m', - '--other_mounts', - dest='other_mounts', - help='Other mount points in the form: ' - 'dir:mounted_dir:options') - parser.add_argument('-s', - '--mount-scripts-only', - dest='mount_scripts_only', - action='store_true', - default=False, - help='Mount only the scripts dir, and not the sources.') - parser.add_argument('passthrough_argv', nargs='*', - help='Command to be executed inside the chroot.') + parser.add_argument( + '-c', + '--chromeos_root', + dest='chromeos_root', + default='../..', + help='ChromeOS root checkout directory.') + parser.add_argument( + '-t', + '--toolchain_root', + dest='toolchain_root', + help='Toolchain root directory.') + parser.add_argument( + '-o', '--output', dest='output', help='Toolchain output directory') + parser.add_argument( + '--sudo', + dest='sudo', + action='store_true', + default=False, + help='Run the command with sudo.') + parser.add_argument( + '-r', + '--third_party', + dest='third_party', + help='The third_party directory to mount.') + parser.add_argument( + '-m', + '--other_mounts', + dest='other_mounts', + help='Other mount points in the form: ' + 'dir:mounted_dir:options') + parser.add_argument( + '-s', + '--mount-scripts-only', + dest='mount_scripts_only', + action='store_true', + default=False, + help='Mount only the scripts dir, and not the sources.') + parser.add_argument( + 'passthrough_argv', + nargs='*', + help='Command to be executed inside the chroot.') options = parser.parse_args(argv) @@ -137,8 +143,10 @@ def Main(argv, return_output=False): m = 'toolchain_root not specified. Will not mount toolchain dirs.' logger.GetLogger().LogWarning(m) else: - tc_dirs = [options.toolchain_root + '/google_vendor_src_branch/gcc', - options.toolchain_root + '/google_vendor_src_branch/binutils'] + tc_dirs = [ + options.toolchain_root + '/google_vendor_src_branch/gcc', + options.toolchain_root + '/google_vendor_src_branch/binutils' + ] for tc_dir in tc_dirs: if not os.path.exists(tc_dir): @@ -154,9 +162,9 @@ def Main(argv, return_output=False): sys.exit(1) if not os.path.exists(chromeos_root + '/src/scripts/build_packages'): - logger.GetLogger( - ).LogError(options.chromeos_root + '/src/scripts/build_packages' - ' not found!') + logger.GetLogger().LogError(options.chromeos_root + + '/src/scripts/build_packages' + ' not found!') parser.print_help() sys.exit(1) @@ -176,16 +184,16 @@ def Main(argv, return_output=False): # Add the third_party mount point if it exists if options.third_party: third_party_dir = options.third_party - logger.GetLogger().LogFatalIf( - not os.path.isdir(third_party_dir), - '--third_party option is not a valid dir.') + logger.GetLogger().LogFatalIf(not os.path.isdir(third_party_dir), + '--third_party option is not a valid dir.') else: - third_party_dir = os.path.abspath('%s/../../../third_party' % - os.path.dirname(__file__)) + third_party_dir = os.path.abspath( + '%s/../../../third_party' % os.path.dirname(__file__)) if os.path.isdir(third_party_dir): - mount_point = MountPoint(third_party_dir, ('%s/%s' % ( - full_mounted_tc_root, os.path.basename(third_party_dir))), + mount_point = MountPoint(third_party_dir, + ('%s/%s' % (full_mounted_tc_root, + os.path.basename(third_party_dir))), getpass.getuser()) mount_points.append(mount_point) @@ -195,8 +203,8 @@ def Main(argv, return_output=False): output = options.toolchain_root + '/output' if output: - mount_points.append(MountPoint(output, full_mounted_tc_root + '/output', - getpass.getuser())) + mount_points.append( + MountPoint(output, full_mounted_tc_root + '/output', getpass.getuser())) # Mount the other mount points mount_points += CreateMountPointsFromString(options.other_mounts, @@ -235,16 +243,16 @@ def Main(argv, return_output=False): inner_command = inner_command[3:] command_file = 'tc_enter_chroot.cmd' command_file_path = chromeos_root + '/src/scripts/' + command_file - retv = command_executer.GetCommandExecuter().RunCommand('sudo rm -f ' + - command_file_path) + retv = command_executer.GetCommandExecuter().RunCommand( + 'sudo rm -f ' + command_file_path) if retv != 0: return retv f = open(command_file_path, 'w') f.write(inner_command) f.close() logger.GetLogger().LogCmd(inner_command) - retv = command_executer.GetCommandExecuter().RunCommand('chmod +x ' + - command_file_path) + retv = command_executer.GetCommandExecuter().RunCommand( + 'chmod +x ' + command_file_path) if retv != 0: return retv |