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