From cdced3d08fad56ae3f4311d7f21d70e393942a0b Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Thu, 2 Jun 2022 17:33:29 -0700 Subject: Rename a method in exec_utils. --- exec_utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'exec_utils.py') diff --git a/exec_utils.py b/exec_utils.py index 7e45d92..0bcfc27 100644 --- a/exec_utils.py +++ b/exec_utils.py @@ -71,7 +71,7 @@ def cmd_showing_output( return p.returncode -def cmd_with_timeout(command: str, timeout_seconds: Optional[float] = None) -> int: +def cmd_exitcode(command: str, timeout_seconds: Optional[float] = None) -> int: """Run a command but do not let it run for more than timeout_seconds. This code doesn't capture or rebroadcast the command's output. It returns the exit value of the command or raises a TimeoutExpired @@ -86,10 +86,10 @@ def cmd_with_timeout(command: str, timeout_seconds: Optional[float] = None) -> i the exit status of the subprocess once the subprocess has exited - >>> cmd_with_timeout('/bin/echo foo', 10.0) + >>> cmd_exitcode('/bin/echo foo', 10.0) 0 - >>> cmd_with_timeout('/bin/sleep 2', 0.01) + >>> cmd_exitcode('/bin/sleep 2', 0.01) Traceback (most recent call last): ... subprocess.TimeoutExpired: Command '['/bin/bash', '-c', '/bin/sleep 2']' timed out after 0.01 seconds @@ -123,7 +123,6 @@ def cmd(command: str, timeout_seconds: Optional[float] = None) -> str: ret = subprocess.run( command, shell=True, - # capture_output=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=True, -- cgit v1.3