diff --git a/config.json b/config.json new file mode 100644 index 0000000..4d35485 --- /dev/null +++ b/config.json @@ -0,0 +1,15 @@ +{ + "virtual-env":{ + "class":"Sandbox", + "config":{ + "3-launchpad":{"requirements":"/Users/steve/Documents/git/repair-file/required.txt","sandbox":"/Users/steve/Documents/git/sandbox"} + } + }, + "processes":{ + "class":"DetailProcess", + "config":{ + "system":["postgresql","couchdb","httpd"] + } + } + +} diff --git a/src/api/index.py b/src/api/index.py new file mode 100644 index 0000000..20f5b19 --- /dev/null +++ b/src/api/index.py @@ -0,0 +1,54 @@ + +from flask import Flask,request +import sys +import os +import json +import re +import monitor +PARAMS = {'context':''} +if len(sys.argv) > 1: + + N = len(sys.argv) + for i in range(1,N): + value = None + if sys.argv[i].startswith('--'): + key = sys.argv[i].replace('-','') + + if i + 1 < N: + value = sys.argv[i + 1] = sys.argv[i+1].strip() + if key and value: + PARAMS[key] = value + + i += 2 + + +app = Flask(__name__) +f = open(PARAMS['path']) +CONFIG = json.loads(f.read()) +HANDLERS= {} +for key in CONFIG : + + className = CONFIG[key]['class'] + ref = "".join(["monitor.",className,"()"]) + ref = eval(ref) + HANDLERS[key] = {"class":ref,"config":CONFIG[key]["config"]} + +f.close() +@app.route('/get/') +def procs(id): + if id in HANDLERS: + handler = HANDLERS[id]["class"] + + conf = HANDLERS[id]["config"] + r = {} + for key in conf: + handler.init(conf[key]) + r[key] = handler.composite() + return json.dumps(r) + else: + return "[]" + pass + + +if __name__== '__main__': + app.run(host='0.0.0.0',debug=True,threaded=True) \ No newline at end of file