def home(request): conf = SvxlinkConf(SVXLINK_CONF) # FIXME: Use some kind of "get_voter()" function to select Voter # section. Hardcoding the section is not a good way. r = conf.get_section("MultiRx") receivers = map(lambda x: conf.get_section(x), r["RECEIVERS"].split(",")) t = conf.get_section("MultiTx") transmitters = map(lambda x: conf.get_section(x), t["TRANSMITTERS"].split(",")) rx_output = [] # iterate over receivers, control if they are online and produce # output for the use of template for i in receivers: rx_output.append({"name": i.get_section_name(), "is_online": i.is_online()}) tx_output = [] for i in transmitters: tx_output.append({"name": i.get_section_name(), "is_online": i.is_online()}) data = {"css_link_main": "active", "receivers": rx_output, "transmitters": tx_output} return render_response(request, "home.html", data)
def node_edit(request): """A page that manipulates TYPE=Voter and TYPE=Multi sections. """ conf = SvxlinkConf(SVXLINK_CONF) if request.method == "POST": rx = ",".join(request.POST.getlist("rx")) tx = ",".join(request.POST.getlist("tx")) # control if any tx, rx are specified. At least one rx and one # tx should be specified. if len(rx) == 0 or len(tx) == 0: return render_response(request, "node_edit_ok.html", { "css_link_client": "active", "error": True }) # FIXME: DO NOT HARDCODE SECTION NAME conf.config.set("MultiTx", "TRANSMITTERS", tx) conf.config.set("MultiRx", "RECEIVERS", rx) conf.write() return render_response(request, "node_edit_ok.html", {"css_link_client": "active"}) else: # FIXME: DO NOT HARDCODE SECTION NAME r = conf.get_section("MultiRx") receivers = r["RECEIVERS"].split(",") t = conf.get_section("MultiTx") transmitters = t["TRANSMITTERS"].split(",") all_nodes = conf.get_remote_nodes() def is_in_rx(node): return node in receivers def is_in_tx(node): return node in transmitters output = [] for node in all_nodes: name = node.get_section_name() output.append({ "name": name, "is_online": node.is_online(), "is_in_rx": is_in_rx(name), "is_in_tx": is_in_tx(name) }) data = {"css_link_client": "active", "nodes": output} return render_response(request, "node_edit.html", data)
def node_edit(request): """A page that manipulates TYPE=Voter and TYPE=Multi sections. """ conf = SvxlinkConf(SVXLINK_CONF) if request.method == "POST": rx = ",".join(request.POST.getlist("rx")) tx = ",".join(request.POST.getlist("tx")) # control if any tx, rx are specified. At least one rx and one # tx should be specified. if len(rx) == 0 or len(tx) == 0: return render_response(request, "node_edit_ok.html", {"css_link_client": "active", "error": True}) # FIXME: DO NOT HARDCODE SECTION NAME conf.config.set("MultiTx", "TRANSMITTERS", tx) conf.config.set("MultiRx", "RECEIVERS", rx) conf.write() return render_response(request, "node_edit_ok.html", {"css_link_client": "active"}) else: # FIXME: DO NOT HARDCODE SECTION NAME r = conf.get_section("MultiRx") receivers = r["RECEIVERS"].split(",") t = conf.get_section("MultiTx") transmitters = t["TRANSMITTERS"].split(",") all_nodes = conf.get_remote_nodes() def is_in_rx(node): return node in receivers def is_in_tx(node): return node in transmitters output = [] for node in all_nodes: name = node.get_section_name() output.append( {"name": name, "is_online": node.is_online(), "is_in_rx": is_in_rx(name), "is_in_tx": is_in_tx(name)} ) data = {"css_link_client": "active", "nodes": output} return render_response(request, "node_edit.html", data)
def home(request): conf = SvxlinkConf(SVXLINK_CONF) # FIXME: Use some kind of "get_voter()" function to select Voter # section. Hardcoding the section is not a good way. r = conf.get_section("MultiRx") receivers = map(lambda x: conf.get_section(x), \ r["RECEIVERS"].split(",")) t = conf.get_section("MultiTx") transmitters = map(lambda x: conf.get_section(x), \ t["TRANSMITTERS"].split(",")) rx_output = [] # iterate over receivers, control if they are online and produce # output for the use of template for i in receivers: rx_output.append({ "name": i.get_section_name(), "is_online": i.is_online() }) tx_output = [] for i in transmitters: tx_output.append({ "name": i.get_section_name(), "is_online": i.is_online() }) data = { "css_link_main": "active", "receivers": rx_output, "transmitters": tx_output } return render_response(request, "home.html", data)