# this is a web interface for simple edits to configuration or editing data # for particular bureaus import configparser import os from bottle import Bottle, request class IhrApp(Bottle): def __init__(self): super(IhrApp, self).__init__() self.name = "IHR App" self.route("/", callback=self.index) self.route("/config/", callback=self.config) self.route("/config/", callback=self.config, method="POST") self.bureaus = [] def index(self): # return a list of active bureaus with links # TODO: allow (de)activation of non-essential bureaus out = """

The Screenless Office

Config Manager

" return out def config(self, bureau): # parse the config and make it into a form out = "

config file for " + bureau + "

\n" basedir = os.path.expanduser("~/.screenless") if bureau == "mgmt": cfgfile = "mgmt.ini" elif bureau == "printers": cfgfile = printers.cfg else: cfgfile = bureau + ".yml" 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 #parse and show the config as a form with open(cfgfile) as cfg: out += cfg.read() return out def register_bureau(self, bureau): self.bureaus.append(bureau) def register_crud(self, data): # adds callbacks for crud operations on a database pass