*: Use action_utils.run instead of subprocess.call

- 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:55 +03:00
1 parent 80e6d940a4
commit bf9005ac48
5 files changed
+15 -17

No files matched your search

+3 -4
View File
@@ -1,18 +1,17 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
"""Shutdown/restart the system."""
import subprocess
from plinth import action_utils
from plinth.actions import privileged
@privileged
def restart():
"""Restart the system."""
subprocess.call('reboot')
action_utils.run('reboot', check=False)
@privileged
def shutdown():
"""Shut down the system."""
subprocess.call(['shutdown', 'now'])
action_utils.run(['shutdown', 'now'], check=False)