Add hacky update system
This commit is contained in:
parent
609d876465
commit
beda044294
4
latty.py
4
latty.py
|
@ -11,16 +11,19 @@ def get_unique():
|
||||||
unique = str(uuid.uuid1().hex)
|
unique = str(uuid.uuid1().hex)
|
||||||
return unique
|
return unique
|
||||||
|
|
||||||
|
|
||||||
def get_datetime():
|
def get_datetime():
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
return now.strftime("%Y-%m-%d %H:%M:%S")
|
return now.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
|
||||||
root_dir = os.path.dirname(os.getcwd())
|
root_dir = os.path.dirname(os.getcwd())
|
||||||
proj_dir = root_dir + '/undercover/'
|
proj_dir = root_dir + '/undercover/'
|
||||||
output_dir = proj_dir + 'outputs/'
|
output_dir = proj_dir + 'outputs/'
|
||||||
base_tex_text = open(proj_dir + "/writing_templates/base.tex", "r").read()
|
base_tex_text = open(proj_dir + "/writing_templates/base.tex", "r").read()
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class CLData():
|
class CLData():
|
||||||
username: str
|
username: str
|
||||||
|
@ -93,5 +96,6 @@ class CLData():
|
||||||
del errors[-2:]
|
del errors[-2:]
|
||||||
return (None, errors)
|
return (None, errors)
|
||||||
|
|
||||||
|
|
||||||
def cleanup(unique):
|
def cleanup(unique):
|
||||||
subprocess.run(['bash', '-c', "rm " + unique + ".*"])
|
subprocess.run(['bash', '-c', "rm " + unique + ".*"])
|
||||||
|
|
11
writing.py
11
writing.py
|
@ -8,6 +8,8 @@ from latty import CLData
|
||||||
import flaskr
|
import flaskr
|
||||||
import flaskr.db as db
|
import flaskr.db as db
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
|
import threading
|
||||||
|
|
||||||
|
|
||||||
writing_blueprint = Blueprint('writing', __name__,)
|
writing_blueprint = Blueprint('writing', __name__,)
|
||||||
|
@ -82,14 +84,21 @@ def dbtest_get():
|
||||||
def update_get():
|
def update_get():
|
||||||
if os.environ['GITLAB_HOOK_TOKEN'] == request.headers['X-Gitlab-Token'] and request.headers['X-Gitlab-Event'] == "Push Hook":
|
if os.environ['GITLAB_HOOK_TOKEN'] == request.headers['X-Gitlab-Token'] and request.headers['X-Gitlab-Event'] == "Push Hook":
|
||||||
print("Update notification received.")
|
print("Update notification received.")
|
||||||
# TODO: Git clone
|
|
||||||
response = make_response("", 200)
|
response = make_response("", 200)
|
||||||
response.mimetype = "text/plain"
|
response.mimetype = "text/plain"
|
||||||
|
threading.Timer(5, git_update, []).start()
|
||||||
return response
|
return response
|
||||||
else:
|
else:
|
||||||
return make_response("", 404)
|
return make_response("", 404)
|
||||||
|
|
||||||
|
|
||||||
|
def git_update():
|
||||||
|
script = os.environ['UPDATE_SCRIPT_PATH']
|
||||||
|
if not script:
|
||||||
|
return
|
||||||
|
subprocess.run(['bash', '-c', "test -f " + script + " && " + script])
|
||||||
|
|
||||||
|
|
||||||
@writing_blueprint.route('/', methods=['POST'])
|
@writing_blueprint.route('/', methods=['POST'])
|
||||||
def index_post():
|
def index_post():
|
||||||
form = CLForm(request.form)
|
form = CLForm(request.form)
|
||||||
|
|
Loading…
Reference in New Issue