-
Notifications
You must be signed in to change notification settings - Fork 7
/
git-inspect.py
51 lines (40 loc) · 1.85 KB
/
git-inspect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from flask import Flask, request, render_template
import logging
import org.btlas.startFromRepo as startWithRespo
from org.btlas.module.indexHelper import IndexHelper
from git.exc import NoSuchPathError, InvalidGitRepositoryError
import jsonpickle
app = Flask(__name__, static_url_path='')
@app.route('/')
def home():
return app.send_static_file('index.html')
@app.route("/allCommit", methods=["POST"])
def allCommit():
return startWithRespo.getAllCommitJSON(request.form['workingDir'])
@app.route("/index", methods=["POST"])
def index():
try:
indexHelper = IndexHelper(request.form['workingDir'])
return indexHelper.getIndexJSON()
except NoSuchPathError as e:
return jsonpickle.encode({"suc":False,"msg":"路径不存在:"+str(e)}, unpicklable=False)
except InvalidGitRepositoryError as e:
return jsonpickle.encode({"suc":False,"msg":"路径不是git仓库:"+str(e)}, unpicklable=False)
except Exception as e:
return jsonpickle.encode({"suc":False,"msg":"系统异常:"+str(e)}, unpicklable=False)
@app.route("/categoryObjects", methods=["POST"])
def categoryObjects():
try:
from org.btlas.startFromObjects import getCategoryObjectsJson
return getCategoryObjectsJson(request.form['workingDir'])
except NoSuchPathError as e:
return jsonpickle.encode({"suc":False,"msg":"路径不存在:"+str(e)}, unpicklable=False)
except InvalidGitRepositoryError as e:
return jsonpickle.encode({"suc":False,"msg":"路径不是git仓库:"+str(e)}, unpicklable=False)
except Exception as e:
return jsonpickle.encode({"suc":False,"msg":"系统异常:"+str(e)}, unpicklable=False)
if __name__ == '__main__':
handler = logging.FileHandler(r'flask.log')
handler.setLevel(logging.DEBUG)
app.logger.addHandler(handler)
app.run(host="0.0.0.0", port=8099, debug=True)