Add hacky update system

This commit is contained in:
Sage Vaillancourt 2022-09-22 19:43:36 +00:00
parent 609d876465
commit beda044294
2 changed files with 14 additions and 1 deletions

View File

@ -11,16 +11,19 @@ def get_unique():
unique = str(uuid.uuid1().hex)
return unique
def get_datetime():
from datetime import datetime
now = datetime.now()
return now.strftime("%Y-%m-%d %H:%M:%S")
root_dir = os.path.dirname(os.getcwd())
proj_dir = root_dir + '/undercover/'
output_dir = proj_dir + 'outputs/'
base_tex_text = open(proj_dir + "/writing_templates/base.tex", "r").read()
@dataclass
class CLData():
username: str
@ -93,5 +96,6 @@ class CLData():
del errors[-2:]
return (None, errors)
def cleanup(unique):
subprocess.run(['bash', '-c', "rm " + unique + ".*"])

View File

@ -8,6 +8,8 @@ from latty import CLData
import flaskr
import flaskr.db as db
import os
import subprocess
import threading
writing_blueprint = Blueprint('writing', __name__,)
@ -82,14 +84,21 @@ def dbtest_get():
def update_get():
if os.environ['GITLAB_HOOK_TOKEN'] == request.headers['X-Gitlab-Token'] and request.headers['X-Gitlab-Event'] == "Push Hook":
print("Update notification received.")
# TODO: Git clone
response = make_response("", 200)
response.mimetype = "text/plain"
threading.Timer(5, git_update, []).start()
return response
else:
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'])
def index_post():
form = CLForm(request.form)