fix link quality again

alfred-data
Nils Schneider 2012-06-04 20:58:17 +02:00
parent 492dec92c1
commit e9ecf8f447
1 changed files with 11 additions and 2 deletions

View File

@ -19,7 +19,7 @@ except NameError:
class NodeDB: class NodeDB:
def __init__(self): def __init__(self):
self._nodes = [] self._nodes = []
self._links = set() self._links = []
# fetch list of links # fetch list of links
def get_links(self): def get_links(self):
@ -29,6 +29,15 @@ class NodeDB:
def get_nodes(self): def get_nodes(self):
return self._nodes return self._nodes
def add_link(self, a, b, q):
l = tuple(sorted((a,b)))
for link in self._links:
if l == link[0]:
if link[1] != str(q):
link[1] += " / " + str(q)
return
self._links.append([l,str(q)])
def maybe_node_by_mac(self, macs): def maybe_node_by_mac(self, macs):
for node in self._nodes: for node in self._nodes:
for mac in macs: for mac in macs:
@ -96,7 +105,7 @@ class NodeDB:
a = self._nodes.index(router) a = self._nodes.index(router)
b = self._nodes.index(neighbor) b = self._nodes.index(neighbor)
self._links.add(tuple((tuple(sorted((a,b))), x['label']))) self.add_link(a, b, x['label'])
for line in lines: for line in lines:
x = json.loads(line) x = json.loads(line)