From 5f2a1d0f398a7159430b2bd877e91e020df5c76f Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sun, 15 Mar 2020 19:45:25 +0100 Subject: Sort out configuration and testing --- rcon.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'rcon.py') diff --git a/rcon.py b/rcon.py index 8c6748e..3df49ab 100644 --- a/rcon.py +++ b/rcon.py @@ -1,7 +1,13 @@ import urwid, os, subprocess, fcntl, glob -SERVER_PATH = "/home/tremded/home@*" -PIPE_PATH = "/home/tremded/home@%s/slacker/pipe" +try: + from local_config import * +except ImportError: + SERVER_PATH = "testing/home@*" + PIPE_PATH = "testing/home@%s/slacker/pipe" + LOG_COMMAND = ["/usr/bin/env", "python3", "testing/log_simulator.py"] + + class JournalViewer: def __init__(self, status, loop): @@ -39,6 +45,8 @@ class JournalViewer: def proc_write(self): self.write(self.pipe.read()) + + class ServerSelectorPopup(urwid.WidgetWrap): def __init__(self, parent, console): self.parent = parent @@ -76,6 +84,8 @@ class ServerSelector(urwid.PopUpLauncher): def get_pop_up_parameters(self): return {'left':0, 'top':1, 'overlay_width':20, 'overlay_height':5} + + class Console: def __init__(self, loop): self.loop = loop @@ -125,14 +135,16 @@ class Console: self.viewer.write("*** Now viewing logs from %s ***" % server) self.edit_pre.button.set_label(server) - self.viewer.proc_open(["journalctl", "-fq", "--user-unit", - "tremded@" + server]) + argv = [arg % server if "%s" in arg else arg for arg in LOG_COMMAND] + self.viewer.proc_open(argv) def execute(self, command): self.viewer.write(PIPE_PATH % self.server) with open(PIPE_PATH % self.server, "w") as fp: fp.write(command + "\n") + + palette = [ ("button", "white", "dark red"), ("button focus", "white, bold", "light red"), -- cgit