diff --git a/main.py b/main.py index b5095d7..5aff984 100644 --- a/main.py +++ b/main.py @@ -10,21 +10,23 @@ if glob.config["git"]["auto_pull_and_restart"]: # Only used on the VPS (Do not e @glob.app.route(glob.config["git"]["webhook_endpoint"], methods = ["POST"]) def git_fetch(): if request.method != "POST": - return "No" + return "No", 400 data = json.loads( request.data.decode() ) if data["secret"] != glob.config["git"]["secret"]: - return "No" - - import subprocess, os, sys - process = subprocess.Popen(["git", "pull"], stdout=subprocess.PIPE) - output = process.communicate()[0] + return "No", 400 + + from subprocess import check_output + output = check_output(["git", "pull", "origin", "master"]) + + print( "GIT: {}".format( output.decode() ) ) if output.decode().split("\n")[-2].find("fail") != -1: - return "Failed to pull changes" + return "Failed to pull changes", 500 # If needed; every open file or connection HAVE to be closed at this point + import os, sys os.execv(sys.executable, ["python"] + sys.argv) # Restart service if glob.config["disable-static-cache"]: @@ -37,7 +39,7 @@ if glob.config["disable-static-cache"]: caching static files. """ return dict(url_for=dated_url_for) - + def dated_url_for(endpoint, **values): if endpoint == "static": filename = values.get("filename", None)