cros_build_lib: rename RunCommand to run
This aligns with the new subprocess.run API.
RunCommand -> run.
SudoRunCommand -> sudo_run.
DebugRunCommand -> dbg_run.
BUG=chromium:1006587
TEST=`./run_tests` passes
Change-Id: I78ebd4e08176d7874b3d3fe537b6ceb292b0241b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1818782
Tested-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Chris McDonald <cjmcdonald@chromium.org>
diff --git a/scripts/cros_sdk.py b/scripts/cros_sdk.py
index 40397f6..797f20b 100644
--- a/scripts/cros_sdk.py
+++ b/scripts/cros_sdk.py
@@ -203,7 +203,7 @@
logging.notice('Creating chroot. This may take a few minutes...')
try:
- cros_build_lib.RunCommand(cmd, print_cmd=False)
+ cros_build_lib.run(cmd, print_cmd=False)
except cros_build_lib.RunCommandError:
raise SystemExit('Running %r failed!' % cmd)
@@ -213,7 +213,7 @@
cmd = MAKE_CHROOT + ['--chroot', chroot_path, '--delete']
try:
logging.notice('Deleting chroot.')
- cros_build_lib.RunCommand(cmd, print_cmd=False)
+ cros_build_lib.run(cmd, print_cmd=False)
except cros_build_lib.RunCommandError:
raise SystemExit('Running %r failed!' % cmd)
@@ -249,7 +249,7 @@
# ThinLTO opens lots of files at the same time.
resource.setrlimit(resource.RLIMIT_NOFILE, (32768, 32768))
- ret = cros_build_lib.RunCommand(
+ ret = cros_build_lib.run(
cmd, print_cmd=False, error_code_ok=True, mute_output=False)
# If we were in interactive mode, ignore the exit code; it'll be whatever
# they last ran w/in the chroot and won't matter to us one way or another.
@@ -303,7 +303,7 @@
try:
logging.notice('Creating snapshot %s from %s in VG %s.', snapshot_name,
chroot_lv, chroot_vg)
- cros_build_lib.RunCommand(cmd, print_cmd=False, capture_output=True)
+ cros_build_lib.run(cmd, print_cmd=False, capture_output=True)
return True
except cros_build_lib.RunCommandError:
raise SystemExit('Running %r failed!' % cmd)
@@ -336,7 +336,7 @@
cmd = ['lvremove', '-f', '%s/%s' % (chroot_vg, snapshot_name)]
try:
logging.notice('Deleting snapshot %s in VG %s.', snapshot_name, chroot_vg)
- cros_build_lib.RunCommand(cmd, print_cmd=False, capture_output=True)
+ cros_build_lib.run(cmd, print_cmd=False, capture_output=True)
except cros_build_lib.RunCommandError:
raise SystemExit('Running %r failed!' % cmd)
@@ -376,17 +376,17 @@
backup_chroot_name = 'chroot-bak-%d' % random.randint(0, 1000)
cmd = ['lvrename', chroot_vg, chroot_lv, backup_chroot_name]
try:
- cros_build_lib.RunCommand(cmd, print_cmd=False, capture_output=True)
+ cros_build_lib.run(cmd, print_cmd=False, capture_output=True)
except cros_build_lib.RunCommandError:
raise SystemExit('Running %r failed!' % cmd)
cmd = ['lvrename', chroot_vg, snapshot_name, chroot_lv]
try:
- cros_build_lib.RunCommand(cmd, print_cmd=False, capture_output=True)
+ cros_build_lib.run(cmd, print_cmd=False, capture_output=True)
except cros_build_lib.RunCommandError:
cmd = ['lvrename', chroot_vg, backup_chroot_name, chroot_lv]
try:
- cros_build_lib.RunCommand(cmd, print_cmd=False, capture_output=True)
+ cros_build_lib.run(cmd, print_cmd=False, capture_output=True)
except cros_build_lib.RunCommandError:
raise SystemExit('Failed to rename %s to chroot and failed to restore '
'%s back to chroot. Failed command: %r' %
@@ -401,18 +401,18 @@
# that don't have the flag should be auto-activated.
chroot_lv_path = '%s/%s' % (chroot_vg, chroot_lv)
cmd = ['lvchange', '-kn', chroot_lv_path]
- cros_build_lib.RunCommand(
+ cros_build_lib.run(
cmd, print_cmd=False, capture_output=True, error_code_ok=True)
# Activate the LV in case the lvchange above was needed. Activating an LV
# that is already active shouldn't do anything, so this is safe to run even if
# the -kn wasn't needed.
cmd = ['lvchange', '-ay', chroot_lv_path]
- cros_build_lib.RunCommand(cmd, print_cmd=False, capture_output=True)
+ cros_build_lib.run(cmd, print_cmd=False, capture_output=True)
cmd = ['lvremove', '-f', '%s/%s' % (chroot_vg, backup_chroot_name)]
try:
- cros_build_lib.RunCommand(cmd, print_cmd=False, capture_output=True)
+ cros_build_lib.run(cmd, print_cmd=False, capture_output=True)
except cros_build_lib.RunCommandError:
raise SystemExit('Failed to remove backup LV %s/%s. Failed command: %r' %
(chroot_vg, backup_chroot_name, cmd))
@@ -441,7 +441,7 @@
'--separator', '\t', chroot_vg
]
try:
- result = cros_build_lib.RunCommand(
+ result = cros_build_lib.run(
cmd, print_cmd=False, redirect_stdout=True)
except cros_build_lib.RunCommandError:
raise SystemExit('Running %r failed!' % cmd)
@@ -586,7 +586,7 @@
)
try:
for cmd in commands:
- cros_build_lib.RunCommand(cmd, print_cmd=False)
+ cros_build_lib.run(cmd, print_cmd=False)
except cros_build_lib.RunCommandError:
raise SystemExit('Running %r failed!' % (cmd,))
@@ -645,12 +645,12 @@
cmd = None # Make cros lint happy.
try:
for cmd in commands:
- cros_build_lib.RunCommand(cmd, print_cmd=False)
+ cros_build_lib.run(cmd, print_cmd=False)
except cros_build_lib.RunCommandError:
# Clean up existing interfaces, if any.
cmd_cleanup = ('ip', 'link', 'del', veth_host)
try:
- cros_build_lib.RunCommand(cmd_cleanup, print_cmd=False)
+ cros_build_lib.run(cmd_cleanup, print_cmd=False)
except cros_build_lib.RunCommandError:
logging.error('running %r failed', cmd_cleanup)
raise SystemExit('Running %r failed!' % (cmd,))
@@ -1070,7 +1070,7 @@
'fstrim.', img_path, extra_gbs)
cmd = ['fstrim', options.chroot]
try:
- cros_build_lib.RunCommand(cmd, print_cmd=False)
+ cros_build_lib.run(cmd, print_cmd=False)
except cros_build_lib.RunCommandError as e:
logging.warning(
'Running fstrim failed. Consider running fstrim on '