FreedomBox/plinth/modules/power/privileged.py
Sunil Mohan Adapa 7870d43c33
power: Use privileged decorator for actions
Tests:

- Reboot works, the process works in the background showing apps page
- Shutdown works, the process works in the background showing apps page

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-08 18:52:47 -04:00

19 lines
330 B
Python

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