mirror of
https://github.com/cwinfo/yggdrasil-map
synced 2024-11-22 08:10:27 +00:00
log graph insertions
This commit is contained in:
parent
22052a3840
commit
2beed33600
@ -19,8 +19,6 @@ class NodeDB:
|
||||
self.con.commit()
|
||||
self.con.close()
|
||||
|
||||
|
||||
|
||||
def insert_node(self, node):
|
||||
now = int(time.time())
|
||||
self.cur.execute('''
|
||||
|
@ -2,13 +2,21 @@ import json
|
||||
from database import NodeDB
|
||||
from graph import Node, Edge
|
||||
import traceback
|
||||
import time
|
||||
|
||||
def insert_graph_data(config, data, mail, ip):
|
||||
def insert_graph_data(config, data, mail, ip, version):
|
||||
try:
|
||||
graph_data = json.loads(data)
|
||||
except ValueError:
|
||||
return 'Invalid JSON'
|
||||
|
||||
log = '[%s] version: %d, mail: %r, nodes: %d, edges: %d' % (
|
||||
time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
version, mail, len(graph_data['nodes']), len(graph_data['edges']))
|
||||
|
||||
with open(config['LOG'], 'a') as f:
|
||||
f.write(log + '\n')
|
||||
|
||||
nodes = dict()
|
||||
edges = []
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
import pygraphviz as pgv
|
||||
import time
|
||||
import json
|
||||
import collections
|
||||
import math
|
||||
import networkx as nx
|
||||
from networkx.algorithms import centrality
|
||||
|
||||
|
@ -33,7 +33,9 @@ def page_sendGraph():
|
||||
|
||||
data = request.form['data']
|
||||
mail = request.form.get('mail', 'none')
|
||||
ret = insert_graph_data(ip=get_ip(), config=app.config, data=data, mail=mail)
|
||||
version = int(request.form.get('version', '1'))
|
||||
ret = insert_graph_data(ip=get_ip(), config=app.config, data=data, mail=mail, version=version)
|
||||
|
||||
if ret == None:
|
||||
return 'OK'
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user