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