FreedomBox/plinth/modules/power/privileged.py
Sunil Mohan Adapa bf9005ac48
*: 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>
2025-09-29 16:58:55 +03:00

18 lines
371 B
Python

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