Merge pull request #36 from thisco-de/master

Fixes iteration over chars in maybe_node_by_mac() when processing neighbor entries
legacy
Nils Schneider 2015-02-01 14:25:54 +01:00
commit 45d920850e
1 changed files with 11 additions and 11 deletions

View File

@ -46,7 +46,7 @@ class NodeDB:
for n in obj: for n in obj:
try: try:
node = self.maybe_node_by_id(n['id']) node = self.maybe_node_by_id(n['id'])
except: except KeyError:
node = Node() node = Node()
node.id = n['id'] node.id = n['id']
node.name = n['name'] node.name = n['name']
@ -81,7 +81,7 @@ class NodeDB:
if 'of' in x: if 'of' in x:
try: try:
node = self.maybe_node_by_mac((x['of'], x['secondary'])) node = self.maybe_node_by_mac((x['of'], x['secondary']))
except: except KeyError:
node = Node() node = Node()
node.lastseen = self.time node.lastseen = self.time
node.firstseen = self.time node.firstseen = self.time
@ -99,7 +99,7 @@ class NodeDB:
try: try:
node = self.maybe_node_by_mac((x['router'], )) node = self.maybe_node_by_mac((x['router'], ))
except: except KeyError:
node = Node() node = Node()
node.lastseen = self.time node.lastseen = self.time
node.firstseen = self.time node.firstseen = self.time
@ -110,15 +110,15 @@ class NodeDB:
try: try:
if 'neighbor' in x: if 'neighbor' in x:
try: try:
node = self.maybe_node_by_mac((x['neighbor'])) node = self.maybe_node_by_mac((x['neighbor'], ))
except: except KeyError:
continue continue
if 'gateway' in x: if 'gateway' in x:
x['neighbor'] = x['gateway'] x['neighbor'] = x['gateway']
node = self.maybe_node_by_mac((x['neighbor'], )) node = self.maybe_node_by_mac((x['neighbor'], ))
except: except KeyError:
node = Node() node = Node()
node.lastseen = self.time node.lastseen = self.time
node.firstseen = self.time node.firstseen = self.time
@ -138,7 +138,7 @@ class NodeDB:
router = self.maybe_node_by_mac((x['router'], )) router = self.maybe_node_by_mac((x['router'], ))
neighbor = self.maybe_node_by_mac((x['neighbor'], )) neighbor = self.maybe_node_by_mac((x['neighbor'], ))
except: except KeyError:
continue continue
# filter TT links merged in previous step # filter TT links merged in previous step
@ -161,7 +161,7 @@ class NodeDB:
if 'primary' in x: if 'primary' in x:
try: try:
node = self.maybe_node_by_mac((x['primary'], )) node = self.maybe_node_by_mac((x['primary'], ))
except: except KeyError:
continue continue
node.id = x['primary'] node.id = x['primary']
@ -172,9 +172,9 @@ class NodeDB:
node = self.maybe_node_by_mac((x['router'], )) node = self.maybe_node_by_mac((x['router'], ))
node.add_mac(x['gateway']) node.add_mac(x['gateway'])
node.clientcount += 1 node.clientcount += 1
except: except KeyError:
pass pass
# don't count node as its own client # don't count node as its own client
for node in self._nodes: for node in self._nodes:
if node.clientcount > 0: if node.clientcount > 0:
@ -207,7 +207,7 @@ class NodeDB:
for mac, alias in aliases.items(): for mac, alias in aliases.items():
try: try:
node = self.maybe_node_by_mac([mac]) node = self.maybe_node_by_mac([mac])
except: except KeyError:
# create an offline node # create an offline node
node = Node() node = Node()
node.add_mac(mac) node.add_mac(mac)