- daemonize IO thread

- add messages, nicer layout to web config editor
workspace
Brendan Howell 5 years ago
parent 5db5495153
commit da32f9a01a

@ -465,7 +465,7 @@ class Bureau(object):
"""
# start the hardware input handler
io_handler = threading.Thread(target=self._run_io)
io_handler = threading.Thread(target=self._run_io, daemon=True)
io_handler.start()
# register commands and api methods
@ -499,7 +499,6 @@ class Bureau(object):
self.log.debug("got method: " + ref)
if (ref in self.commands) or (ref in self.api):
# TODO: cope with data for calls with no params
if ref in self.api:
if data:
data = json.loads(data)

@ -40,9 +40,13 @@ class IhrApp(Bottle):
def bureau_config(self, bureau):
# parse the config and make it into a form
# TODO: add a little html snippet with cfg file docs
templfile = os.path.join(self.tdir, "web_config.html")
template = mako.template.Template(filename=templfile)
basedir = os.path.expanduser("~/.screenless")
msg = ""
if bureau == "mgmt":
cfgfile = "mgmt.ini"
mode = "ini"
@ -54,15 +58,15 @@ class IhrApp(Bottle):
mode = "yaml"
cfgfile = os.path.join(basedir, cfgfile)
if request.method == "POST":
#save all the request.forms stuff to the config
# tell the bureau to restart / reload
# set our message to be "updated config"
print("NOT saving updated ", cfgfile)
pass
with open(cfgfile, "w") as cfg:
cfg.write(request.forms.get("cfgdata"))
# TODO: tell the bureau to restart / reload
msg = "Modified config file saved!"
#parse and show the config as a form
with open(cfgfile) as cfg:
cfgdata = cfg.read()
return template.render_unicode(bureau=bureau, cfgfile=cfgfile, mode=mode, cfgdata=cfgdata)
return template.render_unicode(msg=msg, bureau=bureau, cfgfile=cfgfile, mode=mode, cfgdata=cfgdata)
def register_bureau(self, bureau):
self.bureaus.append(bureau)

@ -4,17 +4,23 @@
<title>Screenless Office - edit ${cfgfile}</title>
<style type="text/css" media="screen">
#editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
height: 40em;
width: 80em;
}
#msg {
width: 40em;
background-color: pink;
height: 3em;
transition: opacity 3s ease-in-out;
text-align: center;
}
</style>
</head>
<body>
<h3>The Screenless Office</h3>
<h4> edit config file <em>${cfgfile}</em></h4>
<div id="msg">${msg}</div>
<div><a href="/">← Main</a></div>
<div id="editor">${cfgdata}</div>
<form id="cfgform" action="/config/${bureau}" method="post">
<input type="hidden" value="${cfgdata}" name="cfgdata_field" id="cfgdata_field" />

Loading…
Cancel
Save