diff --git a/d3nav/client/RUN.sh b/d3nav/client/RUN.sh new file mode 100755 index 0000000..c677968 --- /dev/null +++ b/d3nav/client/RUN.sh @@ -0,0 +1,7 @@ + + +while true +do + nohup ./home.py + sleep 10 +done diff --git a/d3nav/client/d3nav-demo.html b/d3nav/client/d3nav-demo.html index 4548aba..221efe4 100644 --- a/d3nav/client/d3nav-demo.html +++ b/d3nav/client/d3nav-demo.html @@ -1,62 +1,72 @@ +
diff --git a/d3nav/client/home.py b/d3nav/client/home.py index 950f824..f5509f2 100755 --- a/d3nav/client/home.py +++ b/d3nav/client/home.py @@ -1,34 +1,54 @@ #!/usr/bin/env python from bottle import * +from pymongo import MongoClient import time # static files @route('/images/') def image_content(filepath): return static_file(filepath, root='./images') @route('/css/') def css_content(filepath): return static_file(filepath, root='./css') @route('/js/') def js_content(filepath): return static_file(filepath, root='./js') @route('/d3js/') def js_content(filepath): return static_file(filepath, root='./d3js') @route('/style/') def js_content(filepath): return static_file(filepath, root='./style') +@route('/mongoSTATS') +def mongoSTATS(): + global col + + #t = int(request.query['time']) + t = time.time() - 30 + req = {'time': {'$gte': t}, 'type':request.query['type'], 'mode':request.query['mode']} + print req + elt = col.find_one(req) + if elt != None : + resp = { 'time':elt['time'], 'type':elt['type'], 'mode':elt['mode'], 'value':elt['value'] } + else : + resp = { 'value':0 } + print resp + return resp + # home @route('/') def home(): return static_file('d3nav-demo.html', root='.') # MAIN +client = MongoClient('localhost',27017) +db = client.test +col = db.STATS run(host='0.0.0.0', port='8080', reloader=True) diff --git a/d3nav/client/insert.py b/d3nav/client/insert.py new file mode 100755 index 0000000..358f6ba --- /dev/null +++ b/d3nav/client/insert.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +from pymongo import MongoClient +import time, sys + +if len(sys.argv) > 1 : + AWA=float(sys.argv[1]) +else : + AWA=270 + +# MAIN +client = MongoClient('localhost',27017) +db = client.test +col = db.STATS + +col.delete_many({'time': {'$gte': -100000}}) +col.insert_one({ 'time': time.time(), 'type': 'AWA', 'value': AWA, 'mode':'1' }) + +req = {"time": {'$gte': time.time() - 5},'type':'AWA','mode':'1'} +print req +for elt in col.find(req) : + print elt