# gegeven een wleiden.xml zoals geproduceerd door all2one.sh, plot een # grafiekje van het netwerk from common import * import os nodes = xml_to_obj_hierarchy("nodes.xml") ready_nodes_dtd_hierarchy(nodes) out = open('wleiden.dot', 'w') out.write("digraph \"wleiden\" {\n") for node in nodes.nodes: if node.status == 'up': extra = "style=filled" elif node.status == 'down': extra = "color=red" else: extra = "style=dashed" out.write("%s [%s];\n" % (node.name, extra)) for w in node.wirelesss: w.essid = w.essid.replace('.wleiden.net', '') if has_attr(w, 'channel'): out.write("\"%s\" [label=\"%s\\n(%s)\" shape=box %s];\n" % (w.essid, w.essid, w.channel, extra)) for node in nodes.nodes: for link in node.links: if node.status == 'up': extra = "" elif node.status == 'down': extra = "color=red" else: extra = "style=dashed" if is_a(link.iface, 'wireless'): out.write("%s -> \"%s\" [label=\"%s\" %s];\n" % (node.name, link.iface.essid, link.iface.iface, extra)) else: for (node2, link2) in link.peers: if extra == None: if node2.status == 'up': extra = '' elif node2.status == 'down': extra = "color=red" else: extra = "style=dashed" out.write("%s -> %s [label=\"utp\" %s];\n" % (node.name, node2.name, extra)) out.write("}\n")