summaryrefslogtreecommitdiff
path: root/rcon.py
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2020-03-15 19:45:25 +0100
committerPaweł Redman <pawel.redman@gmail.com>2020-03-15 19:45:25 +0100
commit5f2a1d0f398a7159430b2bd877e91e020df5c76f (patch)
tree94f771f17438c606151e69bbd9367a919a7e9643 /rcon.py
parent06d9d0a8be42f29b99b96e4daf4dabba713dacf6 (diff)
Sort out configuration and testing
Diffstat (limited to 'rcon.py')
-rw-r--r--rcon.py20
1 files changed, 16 insertions, 4 deletions
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"),