initial revision, this has a bunch of hard coded stuff, but works
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore Thu Feb 09 15:18:22 2017 -0600
@@ -0,0 +1,3 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Dockerfile Thu Feb 09 15:18:22 2017 -0600
@@ -0,0 +1,20 @@
+RUN mkdir -p /usr/src/app +COPY requirements.txt /usr/src/app/ +RUN pip install --no-cache-dir -r requirements.txt +CMD python bitshifter.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bitshifter.py Thu Feb 09 15:18:22 2017 -0600
@@ -0,0 +1,58 @@
+from flask import Flask, request, make_response +logging.getLogger().setLevel(logging.NOTSET) +@app.route('/hooked', methods=['POST']) + data = request.get_json() + if 'repository' in data: + repo = data.get('repository') + if repo.get('scm') == 'hg' and repo.get('full_name') == 'pidgin/main': + cmd1 = 'hg pull --cwd pidgin bitbucket' + print 'running: {}'.format(cmd1) + out1 = subprocess.check_output(cmd1.split()) + except Exception as exp: + return make_response((exp, 500)) + cmd2 = 'hg push --cwd pidgin --new-branch pidgin.im' + print 'running: {}'.format(cmd2) + out2 = subprocess.check_output(cmd2.split()) + return make_response((output, 200,)) + except subprocess.CalledProcessError as exp: + if exp.returncode == 1: + output = out1 + exp.output + return make_response((output, 200,)) + return make_response((exp, 500)) + except Exception as exp: + return make_response((exp, 500)) + return make_response(('bad request', 400)) +if __name__ == '__main__': + app.run(host='0.0.0.0', port=11101, debug=False) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docker-compose.yml Thu Feb 09 15:18:22 2017 -0600
@@ -0,0 +1,4 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/requirements.txt Thu Feb 09 15:18:22 2017 -0600
@@ -0,0 +1,1 @@