u_boot_pylib: Add a function to run a single command
Add a helper to avoid needing to use a list within a list for this
simple case.
Update existing users of runpipe() to use this where possible.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/rmboard.py b/tools/rmboard.py
index 0c56b14..594fd89 100755
--- a/tools/rmboard.py
+++ b/tools/rmboard.py
@@ -43,18 +43,16 @@
Args:
path: Path to search for and remove
"""
- cmd = ['git', 'grep', path]
- stdout = command.run_pipe([cmd], capture=True, raise_on_error=False).stdout
+ stdout = command.output('git', 'grep', path, raise_on_error=False)
if not stdout:
return
fname = stdout.split(':')[0]
print("Fixing up '%s' to remove reference to '%s'" % (fname, path))
- cmd = ['sed', '-i', '\|%s|d' % path, fname]
- stdout = command.run_pipe([cmd], capture=True).stdout
+ stdout = command.run_one('sed', '-i', rf'\|{path}|d', fname,
+ capture=True).stdout
- cmd = ['git', 'add', fname]
- stdout = command.run_pipe([cmd], capture=True).stdout
+ stdout = command.output('git', 'add', fname)
def rm_board(board):
"""Create a commit which removes a single board
@@ -68,8 +66,7 @@
"""
# Find all MAINTAINERS and Kconfig files which mention the board
- cmd = ['git', 'grep', '-l', board]
- stdout = command.run_pipe([cmd], capture=True).stdout
+ stdout = command.output('git', 'grep', '-l', board)
maintain = []
kconfig = []
for line in stdout.splitlines():
@@ -109,16 +106,14 @@
# Search for Kconfig files in the resulting list. Remove any 'source' lines
# which reference Kconfig files we want to remove
for path in real:
- cmd = ['find', path]
- stdout = (command.run_pipe([cmd], capture=True, raise_on_error=False).
- stdout)
+ stdout = command.output('find', path, raise_on_error=False)
for fname in stdout.splitlines():
if fname.endswith('Kconfig'):
rm_kconfig_include(fname)
# Remove unwanted files
cmd = ['git', 'rm', '-r'] + real
- stdout = command.run_pipe([cmd], capture=True).stdout
+ stdout = command.output(*cmd, capture=True)
## Change the messages as needed
msg = '''arm: Remove %s board
@@ -131,13 +126,11 @@
msg += 'Patch-cc: %s\n' % name
# Create the commit
- cmd = ['git', 'commit', '-s', '-m', msg]
- stdout = command.run_pipe([cmd], capture=True).stdout
+ stdout = command.output('git', 'commit', '-s', '-m', msg)
# Check if the board is mentioned anywhere else. The user will need to deal
# with this
- cmd = ['git', 'grep', '-il', board]
- print(command.run_pipe([cmd], capture=True, raise_on_error=False).stdout)
+ print(command.output('git', 'grep', '-il', board, raise_on_error=False))
print(' '.join(cmd))
for board in sys.argv[1:]: