summaryrefslogtreecommitdiff
path: root/tools/u_boot_pylib/command.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2025-02-03 09:26:45 -0700
committerTom Rini <trini@konsulko.com>2025-03-04 13:31:49 -0600
commit3d094ce28a22690c3d672988af5f161310822603 (patch)
tree5c459f23f717101ef39d7e0bc5fdef4d810507d8 /tools/u_boot_pylib/command.py
parentf8456c91aad8259ab08bdf3654b8ee8c0187a45d (diff)
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>
Diffstat (limited to 'tools/u_boot_pylib/command.py')
-rw-r--r--tools/u_boot_pylib/command.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/u_boot_pylib/command.py b/tools/u_boot_pylib/command.py
index a98dcedd322..0e247355ef6 100644
--- a/tools/u_boot_pylib/command.py
+++ b/tools/u_boot_pylib/command.py
@@ -188,6 +188,21 @@ def run(*cmd, **kwargs):
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