osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43303?usp=email )
Change subject: testenv: subprocess.run with explicit check=False ......................................................................
testenv: subprocess.run with explicit check=False
Make explicit that we want check=False for these subprocess.run commands.
Related: https://docs.astral.sh/ruff/rules/subprocess-run-without-check/ Change-Id: Ia4e85e4fd9aa780a4c8dca433fa95c537c43ddaa --- M .ruff.toml M _testenv/testenv/cmd.py M _testenv/testenv/coredump.py M _testenv/testenv/podman.py M _testenv/testenv/podman_install.py 5 files changed, 9 insertions(+), 5 deletions(-)
Approvals: fixeria: Looks good to me, approved Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve
diff --git a/.ruff.toml b/.ruff.toml index ebf5d74..8a24384 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -17,7 +17,6 @@ "PIE808", # https://docs.astral.sh/ruff/rules/unnecessary-range-start/ "PLC0206", # https://docs.astral.sh/ruff/rules/dict-index-missing-items/ "PLW0602", # https://docs.astral.sh/ruff/rules/global-variable-not-assigned/ - "PLW1510", # https://docs.astral.sh/ruff/rules/subprocess-run-without-check/ "RUF012", # https://docs.astral.sh/ruff/rules/mutable-class-default/ "SIM102", # https://docs.astral.sh/ruff/rules/collapsible-if/ "SIM103", # https://docs.astral.sh/ruff/rules/needless-bool/ diff --git a/_testenv/testenv/cmd.py b/_testenv/testenv/cmd.py index 97e5c0d..06630c0 100644 --- a/_testenv/testenv/cmd.py +++ b/_testenv/testenv/cmd.py @@ -134,6 +134,7 @@ env=generate_env(env), shell=isinstance(cmd, str), stdin=stdin, + check=False, *args, **kwargs, ) diff --git a/_testenv/testenv/coredump.py b/_testenv/testenv/coredump.py index d436551..3c95b15 100644 --- a/_testenv/testenv/coredump.py +++ b/_testenv/testenv/coredump.py @@ -49,7 +49,7 @@ cmd = ["coredumpctl", "-q", "-S", since, "--json=short", "-n1"] logging.debug(f"+ {cmd}")
- p = subprocess.run(cmd, capture_output=True, text=True) + p = subprocess.run(cmd, capture_output=True, text=True, check=False) if p.returncode != 0: logging.debug("No coredump found") return diff --git a/_testenv/testenv/podman.py b/_testenv/testenv/podman.py index eefa911..3641693 100644 --- a/_testenv/testenv/podman.py +++ b/_testenv/testenv/podman.py @@ -189,7 +189,11 @@ try: while True: time.sleep(2) - p = subprocess.run(["podman", "exec", container_name, "touch", "/tmp/watchdog"], stderr=subprocess.DEVNULL) + p = subprocess.run( + ["podman", "exec", container_name, "touch", "/tmp/watchdog"], + stderr=subprocess.DEVNULL, + check=False, + ) if p.returncode: logging.debug("feed_watchdog_loop: podman container has stopped") return @@ -345,7 +349,7 @@ return False
cmd = ["podman", "ps", "-q", "--filter", f"name={container_name}"] - if not subprocess.run(cmd, capture_output=True, text=True).stdout: + if not subprocess.run(cmd, capture_output=True, text=True, check=False).stdout: return False
return True diff --git a/_testenv/testenv/podman_install.py b/_testenv/testenv/podman_install.py index 9f40388..438f875 100644 --- a/_testenv/testenv/podman_install.py +++ b/_testenv/testenv/podman_install.py @@ -66,7 +66,7 @@ for dbg_pkg in get_dbg_pkgs(dep): # Use subprocess.run so we don't get lots of log messages. # Also we don't need to run grep through podman. - grep = subprocess.run(["grep", "-q", f"^{dbg_pkg}$", dbg_pkgs_all]) + grep = subprocess.run(["grep", "-q", f"^{dbg_pkg}$", dbg_pkgs_all], check=False)
if grep.returncode == 0: dbg_pkgs[dep] = dbg_pkg