mirror of
https://github.com/cwinfo/yggdrasil-map
synced 2024-11-24 14:31:35 +00:00
make updateGraph use new crawler result format
This commit is contained in:
parent
74770f51b5
commit
3e913d2aa2
@ -94,7 +94,7 @@ for k,v in selfInfo['response']['self'].iteritems(): rumored.add(v['key'])
|
|||||||
print '{"yggnodes": {'
|
print '{"yggnodes": {'
|
||||||
while len(rumored) > 0:
|
while len(rumored) > 0:
|
||||||
for k in rumored:
|
for k in rumored:
|
||||||
handleNodeInfoResponse(k, doRequest(getNodeInfoRequest(v['key'])))
|
handleNodeInfoResponse(k, doRequest(getNodeInfoRequest(k)))
|
||||||
break
|
break
|
||||||
rumored.remove(k)
|
rumored.remove(k)
|
||||||
print '\n}}'
|
print '\n}}'
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from flask import Config
|
|
||||||
from database import NodeDB
|
|
||||||
import graphPlotter
|
import graphPlotter
|
||||||
import cgi
|
import cgi
|
||||||
|
|
||||||
@ -35,9 +33,16 @@ def generate_graph(time_limit=60*60*3):
|
|||||||
data = json.loads(response.read())["yggnodes"]
|
data = json.loads(response.read())["yggnodes"]
|
||||||
|
|
||||||
toAdd = []
|
toAdd = []
|
||||||
for ip in data:
|
for key in data:
|
||||||
info = NodeInfo(ip, data[ip][0])
|
if 'address' not in data[key] or 'coords' not in data[key]: continue
|
||||||
if len(data[ip]) >= 3: info.label = data[ip][2]
|
ip = data[key]['address']
|
||||||
|
coords = data[key]['coords']
|
||||||
|
info = NodeInfo(ip, coords)
|
||||||
|
if 'nodeinfo' in data[key]:
|
||||||
|
if 'name' in data[key]['nodeinfo']:
|
||||||
|
label = data[key]['nodeinfo']['name']
|
||||||
|
if type(label) == str and len(label) <= 32:
|
||||||
|
info.label = label
|
||||||
info.label = cgi.escape(info.label)
|
info.label = cgi.escape(info.label)
|
||||||
toAdd.append(info)
|
toAdd.append(info)
|
||||||
|
|
||||||
@ -68,16 +73,5 @@ def generate_graph(time_limit=60*60*3):
|
|||||||
with open('static/graph.json', 'w') as f:
|
with open('static/graph.json', 'w') as f:
|
||||||
f.write(js)
|
f.write(js)
|
||||||
|
|
||||||
|
|
||||||
def load_graph_from_db(time_limit):
|
|
||||||
config = Config('./')
|
|
||||||
config.from_pyfile('web_config.cfg')
|
|
||||||
|
|
||||||
with NodeDB(config) as db:
|
|
||||||
nodes = db.get_nodes(time_limit)
|
|
||||||
edges = db.get_edges(nodes, 60*60*24*7)
|
|
||||||
return (nodes, edges)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
generate_graph()
|
generate_graph()
|
||||||
|
Loading…
Reference in New Issue
Block a user