*: Use action_utils.run instead of subprocess.run

- 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:53 +03:00
1 parent 355812c9f2
commit 61ff15a04f
36 files changed
+257 -244

No files matched your search

+6 -4
View File
@@ -7,6 +7,7 @@ import shutil
import subprocess
import tempfile
from plinth import action_utils
from plinth.actions import privileged, secret_str
from plinth.utils import generate_password
@@ -26,8 +27,8 @@ def get_php_command():
version = ''
try:
process = subprocess.run(['dpkg', '-s', 'php'], stdout=subprocess.PIPE,
check=True)
process = action_utils.run(['dpkg', '-s', 'php'],
stdout=subprocess.PIPE, check=True)
for line in process.stdout.decode().splitlines():
if line.startswith('Version:'):
version = line.split(':')[-1].split('+')[0].strip()
@@ -57,8 +58,9 @@ def setup():
'--scriptpath=/mediawiki', '--passfile',
password_file_handle.name, 'Wiki', 'admin'
])
subprocess.run(['chmod', '-R', 'o-rwx', data_dir], check=True)
subprocess.run(['chown', '-R', 'www-data:www-data', data_dir], check=True)
action_utils.run(['chmod', '-R', 'o-rwx', data_dir], check=True)
action_utils.run(['chown', '-R', 'www-data:www-data', data_dir],
check=True)
conf_file = pathlib.Path(CONF_FILE)
if not conf_file.exists():