*: Use action_utils.run instead of subprocess.check_output

- This is to capture stdout and stderr and transmit that from privileged daemon
back to the service to be displayed in HTML.

Tests:

- Unit tests and code checks pass.

- Some of the modified actions work as expected.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa authored and Veiko Aasa committed 2025-09-29 16:58:56 +03:00
1 parent bf9005ac48
commit b253166f6d
17 files changed
+101 -72

No files matched your search

+3 -4
View File
@@ -1,8 +1,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""Configuration helper for WireGuard."""
import subprocess
from plinth import action_utils
from plinth.actions import privileged
SERVER_INTERFACE = 'wg0'
@@ -11,8 +10,8 @@ SERVER_INTERFACE = 'wg0'
@privileged
def get_info() -> dict[str, dict]:
"""Return info for each configured interface."""
output = subprocess.check_output(['wg', 'show', 'all',
'dump']).decode().strip()
output = action_utils.run(['wg', 'show', 'all', 'dump'],
check=True).stdout.decode().strip()
lines = output.split('\n')
interfaces: dict[str, dict] = {}
for line in lines: