This repository has been archived by the owner on Mar 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathendpoint.py
112 lines (85 loc) · 2.56 KB
/
endpoint.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from flask import Flask, redirect, render_template
from src.gitlab_log import GitLabLog as GL
from argparse import ArgumentParser, ArgumentError
import git_treasures
import configparser
import sys
import os
config = configparser.ConfigParser()
def parse_args():
parser = ArgumentParser()
try:
parser.add_argument(
'-d', '--dev',
action='store_true',
required=False,
help='Run the development version of the script')
parser.add_argument(
'-tr', '--testrail',
action='store_true',
required=False,
help='If true, will reconcile TestRail after Trello is complete.')
parser.add_argument(
'-r', '--results',
action='store_true',
required=False,
help='If true, will run test results mode.')
parser.add_argument(
'-p', '--persist',
action='store_true',
required=False,
help='If true, will only persist TestRail results.')
except ArgumentError as err:
raise err
else:
return parser.parse_args()
try:
config.read(os.path.join('config', 'config.ini'))
except OSError as e:
print(e, "Cannot get settings from config file")
sys.exit(1)
db_path = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"data",
"git_treasures.db"
)
app = Flask(__name__)
app.secret_key = config["flask"]["secret_key"]
@app.route("/")
@app.route("/index.html")
def home():
commit = GL.get_latest_stored_commit(db_path)
commit_data = dict(
date = commit[2],
hash = commit[1],
author = commit[3],
message = commit[4]
)
return render_template("index.html", commit_data=commit_data)
@app.route("/git_treasures")
def hit_endpoint():
args = parse_args()
git_treasures.main(args)
return redirect("index.html", code=302)
@app.route("/git_treasures_dev")
def hit_test_endpoint():
args = parse_args()
args.dev = True
git_treasures.main(args)
return redirect("index.html", code=302)
@app.route("/git_treasures_testrail")
def hit_testrail_endpoint():
args = parse_args()
args.testrail = True
git_treasures.main(args)
return redirect("index.html", code=302)
@app.route("/git_treasures_testrail_dev")
def hit_testrail_test_endpoint():
args = parse_args()
args.testrail = True
git_treasures.main(args)
return redirect("index.html", code=302)
if __name__ == "__main__":
app.run(debug=False)