Exemplo n.º 1
0
def run(query):
    maintempl = Template("webadmintemplate.templ")
    subtempl = Template("adminiobindingstempl.templ")
    conf = config.Config()

    if query.has_key("ok"):
        conf.setIOBinding(query["pubaddr"],query["nickname"], query["interface"], query["address"])       

    selectdata = "".join(["<option value=\"%s\">%s</option>" % (r[0],r[3]) for r in conf.getInterfaces()])
    subtempl.setKey("selectdata", selectdata)

    arr = []
    for r in conf.getIOBindings():
        buff = ""
        selected = ""
        for i in conf.getInterfaces():
            if int(i[0]) == int(r[1]):
                selected = "selected"
            else:
                selected = ""

            buff += '<option value="%s" %s>%s</option>' % (i[0], selected, i[3])

        arr.append({"nickname": str(r[3]), "selectdata": str(buff), "address": r[2], "publicaddress": r[0]})

    
    subtempl.setKeyFromArr("list", arr)
    maintempl.setKey("contents", subtempl.getRendered())
    return maintempl.getRendered()
Exemplo n.º 2
0
def run(query):
    maintempl = Template("webadmintemplate.templ")
    subtempl = Template("admininterfaces.templ")
    conf = config.Config()

    if query.has_key("ok"):
        conf.setInterface(query["interfaceid"], query["interface"], query["nickname"], query["argument"])

    interfacelist = getInterfaceList()
    subtempl.setKey("selectdata", "".join(["<option value=\"%s\">%s</option>" % (s,s) for s in interfacelist]))

    arr = []
    for r in conf.getInterfaces():
        buff = ""
        for s in interfacelist:
            if s == r[1]:
                selected = "selected"
            else:
                selected = ""

            buff += '<option value="%s" %s>%s</option>' % (s, selected, s)

        arr.append({"interfaceid": r[0], "selectdata": buff, "nickname": r[3], "argument": r[2]})

    subtempl.setKeyFromArr("list", arr)
    maintempl.setKey("contents", subtempl.getRendered())
    return maintempl.getRendered()
Exemplo n.º 3
0
def run(query):
    conf = config.Config()
    maintempl = Template("webadmintemplate.templ")
    subtempl = Template("adminconfigvalues.templ")

    if query.has_key("ok"):
        methods = {"float": float, "int": int, "str": str}
        value = methods[query["type"]](query["value"])
        conf.setValue(query["name"], value)
    
    buff = ""

    arr = []
    for r in conf.getAllValues():
        buff = ""
        for s,f in [["int","Integer"],["float","Float"],["str","String"]]:
            if s == r[2]:
                selected = "selected"
            else:
                selected = ""
                
            buff += "<option value=\"%s\" %s>%s</option>" % (s,selected,f)

        arr.append({"name": r[0], "value": r[1], "select": buff})
        
    subtempl.setKeyFromArr("list", arr)
    maintempl.setKey("contents", subtempl.getRendered())
    return maintempl.getRendered()
Exemplo n.º 4
0
def run(query):
    maintempl = Template("webadmintemplate.templ")
    subtempl = Template("adminutilities.templ")
    conf = config.Config()

    if query.has_key("xmlrpcok") and query.has_key("xmlrpccommand"):
        port = conf.getValue("xmlport")
        subtempl.setKey("xml_msg", "<font style=\"color:green;\">XML-PRC Command was send sucessfully</font><br>")
        subtempl.setKey("prevcommand", query["xmlrpccommand"])
    else:
        subtempl.setKey("prevcommand", "")
        subtempl.setKey("xml_msg", "")


    maintempl.setKey("contents", subtempl.getRendered())
    return maintempl.getRendered()
Exemplo n.º 5
0
def run(query):
    templ = Template("webadmintemplate.templ")
    templ.setKey("contents", "<h1>Welcome</h1><i>Choose activity in the menu to the left</i>")
    return templ.getRendered()