Added daemon mode

This commit is contained in:
Mark Qvist 2022-05-17 13:11:04 +02:00
parent 34b377bafe
commit c6e26e7f7f
10 changed files with 46 additions and 14 deletions

View file

@ -4,5 +4,5 @@ import nomadnet
class MenuUI:
def __init__(self):
RNS.log("Menu UI not implemented", RNS.LOG_ERROR)
RNS.log("Menu UI not implemented", RNS.LOG_ERROR, _override_destination=True)
nomadnet.panic()

16
nomadnet/ui/NoneUI.py Normal file
View file

@ -0,0 +1,16 @@
import RNS
import nomadnet
import time
from nomadnet import NomadNetworkApp
class NoneUI:
def __init__(self):
self.app = NomadNetworkApp.get_shared_instance()
self.app.ui = self
RNS.log("Nomad Network started in daemon mode, all further messages are logged to "+str(self.app.logfilepath), RNS.LOG_INFO, _override_destination=True)
while True:
time.sleep(1)

View file

@ -12,11 +12,15 @@ UI_MENU = 0x01
UI_TEXT = 0x02
UI_GRAPHICAL = 0x03
UI_WEB = 0x04
UI_MODES = [UI_MENU, UI_TEXT, UI_GRAPHICAL, UI_WEB]
UI_MODES = [UI_NONE, UI_MENU, UI_TEXT, UI_GRAPHICAL, UI_WEB]
def spawn(uimode):
if uimode in UI_MODES:
RNS.log("Starting user interface...", RNS.LOG_INFO)
if uimode == UI_NONE:
RNS.log("Starting Nomad Network daemon...", RNS.LOG_INFO)
else:
RNS.log("Starting user interface...", RNS.LOG_INFO)
if uimode == UI_MENU:
from .MenuUI import MenuUI
return MenuUI()
@ -29,8 +33,11 @@ def spawn(uimode):
elif uimode == UI_WEB:
from .WebUI import WebUI
return WebUI()
elif uimode == UI_NONE:
from .NoneUI import NoneUI
return NoneUI()
else:
return None
else:
RNS.log("Invalid UI mode", RNS.LOG_ERROR)
RNS.log("Invalid UI mode", RNS.LOG_ERROR, _override_destination=True)
nomadnet.panic()

View file

@ -563,7 +563,7 @@ class KnownNodes(urwid.WidgetWrap):
self.pile = urwid.Pile([urwid.Text(("warning_text", g["info"]+"\n"), align="center"), SelectText(("warning_text", "Currently, no nodes are known\n\n"), align="center")])
self.display_widget = urwid.Filler(self.pile, valign="top", height="pack")
urwid.WidgetWrap.__init__(self, urwid.AttrMap(urwid.LineBox(self.display_widget, title="Known Nodes"), widget_style))
urwid.WidgetWrap.__init__(self, urwid.AttrMap(urwid.LineBox(self.display_widget, title="Saved Nodes"), widget_style))
def keypress(self, size, key):
if key == "up" and (self.no_content or self.ilb.first_item_is_selected()):