FreedomBox/plinth/modules/help/privileged.py
Sunil Mohan Adapa 1027b624aa
help: Use privileged decorator for actions
Tests:

- Functional tests work
- Accessing help/status-log/ works and last 100 logs lines are shown.
  - When there are no logs, '--no entries--' message is shown.

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

15 lines
393 B
Python

# SPDX-License-Identifier: AGPL-3.0-or-later
"""Actions for help module."""
import subprocess
from plinth.actions import privileged
@privileged
def get_logs() -> str:
"""Get latest FreedomBox logs."""
command = ['journalctl', '--no-pager', '--lines=100', '--unit=plinth']
process = subprocess.run(command, check=True, stdout=subprocess.PIPE)
return process.stdout.decode()