aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Fink2026-09-27 21:13:54 +0200
committerDennis Fink2026-09-27 21:13:54 +0200
commit731a25e096cf9af3c0c5b3303796df7b3e91df36 (patch)
tree974e38cde255cec241374e42df723f5474cac544
parent742c5f38a9a9ede62102d692bf0591843ae9dea6 (diff)
downloadprometheus-pacman-exporter-731a25e096cf9af3c0c5b3303796df7b3e91df36.tar.gz
prometheus-pacman-exporter-731a25e096cf9af3c0c5b3303796df7b3e91df36.zip
fix(commands): quote command arguments in diagnostics
Format executed commands with shlex.join() so debug and error messages preserve argument boundaries and shell quoting. Reuse the formatted command string for both command logging and failure reporting.
Diffstat (limited to '')
-rw-r--r--prometheus_pacman_exporter/__init__.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/prometheus_pacman_exporter/__init__.py b/prometheus_pacman_exporter/__init__.py
index 3e29849..0125187 100644
--- a/prometheus_pacman_exporter/__init__.py
+++ b/prometheus_pacman_exporter/__init__.py
@@ -135,12 +135,13 @@ def run_command(
:param accepted_exit_codes: Exit codes considered successful.
:return: Completed process with stdout and stderr captured.
"""
- debug("Running command", " ".join(command), err=True)
+ command_string = shlex.join(command)
+ debug("Running command", command_string, err=True)
result = subprocess.run(command, capture_output=True, encoding="utf-8", check=False)
if result.returncode not in accepted_exit_codes:
error(
- f"Command ({' '.join(command)}) failed with exit code {result.returncode}"
+ f"Command ({command_string}) failed with exit code:", str(result.returncode)
)
if result.stderr:
error("stderr:", result.stderr.strip())