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/u_boot_pylib/command.py b/tools/u_boot_pylib/command.py
index a98dced..0e24735 100644
--- a/tools/u_boot_pylib/command.py
+++ b/tools/u_boot_pylib/command.py
@@ -188,6 +188,21 @@
return run_pipe([cmd], **kwargs).stdout
+def run_one(*cmd, **kwargs):
+ """Run a single command
+
+ Note that you must add 'capture' to kwargs to obtain non-empty output
+
+ Args:
+ *cmd (list of str): Command to run
+ **kwargs (dict of args): Extra arguments to pass in
+
+ Returns:
+ CommandResult: output of command
+ """
+ return run_pipe([cmd], **kwargs)
+
+
def run_list(cmd):
"""Run a command and return its output
diff --git a/tools/u_boot_pylib/tools.py b/tools/u_boot_pylib/tools.py
index 0499a75..1afd289 100644
--- a/tools/u_boot_pylib/tools.py
+++ b/tools/u_boot_pylib/tools.py
@@ -376,7 +376,7 @@
args = tuple(extra_args) + args
name = os.path.expanduser(name) # Expand paths containing ~
all_args = (name,) + args
- result = command.run_pipe([all_args], capture=True, capture_stderr=True,
+ result = command.run_one(*all_args, capture=True, capture_stderr=True,
env=env, raise_on_error=False, binary=binary)
if result.return_code:
if raise_on_error: