Improved handling of invalid nodes data.
This commit is contained in:
parent
1c8600435e
commit
9c16434c0e
|
@ -43,8 +43,9 @@ class NodeHierarchy(object):
|
|||
def __createNodeObjects__(self):
|
||||
nodes = {}
|
||||
for nodeID, nodeValue in self.__hopglass.nodes.items():
|
||||
print('Create Node object #',len(nodes), '\r',end = '')
|
||||
nodes[nodeID] = Node(nodeValue)
|
||||
if nodeValue['nodeinfo']['node_id']:
|
||||
print('Create Node object #',len(nodes), '\r',end = '')
|
||||
nodes[nodeID] = Node(nodeValue)
|
||||
print('')
|
||||
return nodes
|
||||
|
||||
|
|
|
@ -26,18 +26,19 @@ class GlobalGraph(Graph):
|
|||
|
||||
def __getConnectedNodes__(self, nodeID, trace = []):
|
||||
neighNodeIDs = self.getNeighbourNodeIDsForNodeID(nodeID)
|
||||
trace_new = trace[:] + [x for x in neighNodeIDs if x not in trace]
|
||||
trace_new = list(set(trace + neighNodeIDs))
|
||||
for neighNodeID in neighNodeIDs:
|
||||
if neighNodeID not in trace:
|
||||
trace_new = trace_new + [x for x in self.__getConnectedNodes__(neighNodeID, trace_new) if x not in trace_new]
|
||||
trace_new = list(set(trace_new + self.__getConnectedNodes__(neighNodeID, trace_new)))
|
||||
return trace_new
|
||||
|
||||
def __createLocalCloudByNodesList__(self, nodesIDList):
|
||||
nodes = {}
|
||||
links = []
|
||||
for nodeID in nodesIDList:
|
||||
nodes[nodeID] = self.__nodes__[nodeID]
|
||||
links = links + [x for x in self.getLinksByNodeID(nodeID) if x not in links]
|
||||
if nodeID:
|
||||
nodes[nodeID] = self.__nodes__[nodeID]
|
||||
links = list(set(links + self.getLinksByNodeID(nodeID)))
|
||||
return LocalGraph(nodes, links, self.__enableDebugPrinting__)
|
||||
|
||||
def __debugPrint__(self):
|
||||
|
|
|
@ -26,7 +26,7 @@ class Graph(object):
|
|||
if link.isVpn == False:
|
||||
endpoints = link.getEndpointNodeIDs(getGateways = False)
|
||||
if nodeID in endpoints:
|
||||
neighNodeIDs = neighNodeIDs + [x for x in endpoints if x not in neighNodeIDs]
|
||||
neighNodeIDs = list(set(neighNodeIDs + endpoints))
|
||||
return neighNodeIDs
|
||||
|
||||
def getLinksByNodeID(self, nodeID):
|
||||
|
|
|
@ -19,13 +19,16 @@ class NodeInit(object):
|
|||
return {}
|
||||
|
||||
def __getAutoupdaterStatus__(self):
|
||||
if 'autoupdater' in self.__jsonObject__['nodeinfo']['software']:
|
||||
try:
|
||||
return self.__jsonObject__['nodeinfo']['software']['autoupdater']['enabled']
|
||||
else:
|
||||
except:
|
||||
return False
|
||||
|
||||
def __getBranch__(self):
|
||||
return self.__jsonObject__.get('nodeinfo', {}).get('software', {}).get('autoupdater', {}).get('branch', None)
|
||||
try:
|
||||
return self.__jsonObject__['nodeinfo']['software']['autoupdater']['branch']
|
||||
except:
|
||||
return None
|
||||
|
||||
def __getGeo__(self):
|
||||
geo = {}
|
||||
|
|
Loading…
Reference in a new issue