Initial commit
This commit is contained in:
31
gitlab-listener
Executable file
31
gitlab-listener
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from subprocess import call
|
||||
|
||||
import config
|
||||
|
||||
MY_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
try:
|
||||
from flask import Flask, request
|
||||
except ImportError:
|
||||
call(". " + os.path.join(MY_DIR, "venv", "bin", "activate") + "; " + " ".join(sys.argv), shell=True)
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
COMMAND = os.path.join(MY_DIR, "update-keys")
|
||||
|
||||
@app.route("/", methods=['POST'])
|
||||
def commit ():
|
||||
key = request.args.get('key', '')
|
||||
if not key == config.GITLAB_KEY:
|
||||
return "not ok"
|
||||
|
||||
time.sleep(1)
|
||||
call([COMMAND])
|
||||
return "ok"
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host=config.LISTENER_ADDRESS, port=config.LISTENER_PORT)
|
Reference in New Issue
Block a user