mirror of
https://github.com/akuker/RASCSI.git
synced 2025-02-18 01:31:02 +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):
|
def get_logs(lines, scope):
|
||||||
"""
|
"""
|
||||||
Takes (int) lines and (str) 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.
|
Returns either the decoded log output, or the stderr output of journalctl.
|
||||||
"""
|
"""
|
||||||
if scope != "all":
|
line_param = []
|
||||||
|
scope_param = []
|
||||||
|
if lines:
|
||||||
|
line_param = ["-n", lines]
|
||||||
|
if scope:
|
||||||
|
scope_param = ["-u", scope]
|
||||||
process = run(
|
process = run(
|
||||||
["journalctl", "-n", lines, "-u", scope],
|
["journalctl"] + line_param + scope_param,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
check=True,
|
check=True,
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
process = run(
|
|
||||||
["journalctl", "-n", lines],
|
|
||||||
capture_output=True,
|
|
||||||
check=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
return process.returncode, process.stdout.decode("utf-8")
|
return process.returncode, process.stdout.decode("utf-8")
|
||||||
|
|
||||||
|
@ -604,17 +604,20 @@
|
|||||||
<input name="lines" type="number" value="200" min="1" size="4">
|
<input name="lines" type="number" value="200" min="1" size="4">
|
||||||
<label for="scope">{{ _("Scope:") }}</label>
|
<label for="scope">{{ _("Scope:") }}</label>
|
||||||
<select name="scope">
|
<select name="scope">
|
||||||
<option value="all">
|
<option value="">
|
||||||
all
|
{{ _("All logs") }}
|
||||||
</option>
|
</option>
|
||||||
<option value="rascsi">
|
<option value="rascsi">
|
||||||
rascsi.service
|
rascsi
|
||||||
</option>
|
</option>
|
||||||
<option value="rascsi-web">
|
<option value="rascsi-web">
|
||||||
rascsi-web.service
|
rascsi-web
|
||||||
</option>
|
</option>
|
||||||
<option value="rascsi-oled">
|
<option value="rascsi-oled">
|
||||||
rascsi-oled.service
|
rascsi-oled
|
||||||
|
</option>
|
||||||
|
<option value="rascsi-ctrlboard">
|
||||||
|
rascsi-ctrlboard
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<input type="submit" value="{{ _("Show Logs") }}">
|
<input type="submit" value="{{ _("Show Logs") }}">
|
||||||
|
@ -435,8 +435,8 @@ def show_logs():
|
|||||||
"""
|
"""
|
||||||
Displays system logs
|
Displays system logs
|
||||||
"""
|
"""
|
||||||
lines = request.form.get("lines") or "200"
|
lines = request.form.get("lines")
|
||||||
scope = request.form.get("scope") or "all"
|
scope = request.form.get("scope")
|
||||||
|
|
||||||
returncode, logs = sys_cmd.get_logs(lines, scope)
|
returncode, logs = sys_cmd.get_logs(lines, scope)
|
||||||
if returncode == 0:
|
if returncode == 0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user