init
This commit is contained in:
parent
e76e20e86d
commit
fafdbdee24
1
.gitignore
vendored
1
.gitignore
vendored
@ -128,4 +128,5 @@ dmypy.json
|
|||||||
|
|
||||||
# Pyre type checker
|
# Pyre type checker
|
||||||
.pyre/
|
.pyre/
|
||||||
|
.idea
|
||||||
|
|
||||||
|
11
Pipfile
Normal file
11
Pipfile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[[source]]
|
||||||
|
name = "pypi"
|
||||||
|
url = "https://pypi.org/simple"
|
||||||
|
verify_ssl = true
|
||||||
|
|
||||||
|
[dev-packages]
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
|
||||||
|
[requires]
|
||||||
|
python_version = "3.6"
|
3
dest.json
Normal file
3
dest.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"data_cleaning": "/data/ansible/ansible_xdata/roles/cleaning/files"
|
||||||
|
}
|
29
main.py
Normal file
29
main.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
from flask import Flask, request, json, jsonify
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/hook', methods=['POST'])
|
||||||
|
def push_hook():
|
||||||
|
data = json.loads(request.get_data(as_text=True))
|
||||||
|
name = data['repository']['name']
|
||||||
|
clone_url = data['repository']['clone_url']
|
||||||
|
with open('dest.json', 'r', encoding='utf8') as f:
|
||||||
|
dest_dict = json.load(f)
|
||||||
|
dest = os.path.join(dest_dict[name], f'{name}.tar.gz')
|
||||||
|
download(name, clone_url, dest)
|
||||||
|
return jsonify({'msg': 'ok'})
|
||||||
|
|
||||||
|
|
||||||
|
def download(name, clone_url, dest):
|
||||||
|
os.system(f'rm -rf /tmp/{name}')
|
||||||
|
os.system(f'git clone {clone_url} /tmp/{name}')
|
||||||
|
os.system(f'cd /tmp && tar -czvf {dest} {name} ')
|
||||||
|
os.system(f'rm -rf /tmp/{name}')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print(__name__)
|
||||||
|
app.run(host='0.0.0.0', port=5000)
|
Loading…
Reference in New Issue
Block a user