mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-30 05:29:47 +00:00
Improve logic for the get_logs() method. Add rascsi-ctrlboard service. (#714)
This commit is contained in:
parent
0e8d89e827
commit
da02eccb2e
@ -149,21 +149,20 @@ class SysCmds:
|
||||
def get_logs(lines, scope):
|
||||
"""
|
||||
Takes (int) lines and (str) scope.
|
||||
If scope is a None equivalent, all syslogs are returned.
|
||||
Returns either the decoded log output, or the stderr output of journalctl.
|
||||
"""
|
||||
if scope != "all":
|
||||
process = run(
|
||||
["journalctl", "-n", lines, "-u", scope],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
else:
|
||||
process = run(
|
||||
["journalctl", "-n", lines],
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
line_param = []
|
||||
scope_param = []
|
||||
if lines:
|
||||
line_param = ["-n", lines]
|
||||
if scope:
|
||||
scope_param = ["-u", scope]
|
||||
process = run(
|
||||
["journalctl"] + line_param + scope_param,
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
if process.returncode == 0:
|
||||
return process.returncode, process.stdout.decode("utf-8")
|
||||
|
||||
|
@ -604,17 +604,20 @@
|
||||
<input name="lines" type="number" value="200" min="1" size="4">
|
||||
<label for="scope">{{ _("Scope:") }}</label>
|
||||
<select name="scope">
|
||||
<option value="all">
|
||||
all
|
||||
<option value="">
|
||||
{{ _("All logs") }}
|
||||
</option>
|
||||
<option value="rascsi">
|
||||
rascsi.service
|
||||
rascsi
|
||||
</option>
|
||||
<option value="rascsi-web">
|
||||
rascsi-web.service
|
||||
rascsi-web
|
||||
</option>
|
||||
<option value="rascsi-oled">
|
||||
rascsi-oled.service
|
||||
rascsi-oled
|
||||
</option>
|
||||
<option value="rascsi-ctrlboard">
|
||||
rascsi-ctrlboard
|
||||
</option>
|
||||
</select>
|
||||
<input type="submit" value="{{ _("Show Logs") }}">
|
||||
|
@ -435,8 +435,8 @@ def show_logs():
|
||||
"""
|
||||
Displays system logs
|
||||
"""
|
||||
lines = request.form.get("lines") or "200"
|
||||
scope = request.form.get("scope") or "all"
|
||||
lines = request.form.get("lines")
|
||||
scope = request.form.get("scope")
|
||||
|
||||
returncode, logs = sys_cmd.get_logs(lines, scope)
|
||||
if returncode == 0:
|
||||
|
Loading…
Reference in New Issue
Block a user