From 5d0d4a46bb399176df10276f3c4e54905427faf0 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sun, 15 Jul 2018 08:37:00 +0200 Subject: [PATCH] [enh] new cli command to had a job --- add_job.py | 23 +++++++++++++++++++++++ run.py | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 add_job.py diff --git a/add_job.py b/add_job.py new file mode 100644 index 0000000..2a33f22 --- /dev/null +++ b/add_job.py @@ -0,0 +1,23 @@ +import argh +import requests + + +def main(name, url_or_path, test_type="stable", yunohost_version="unstable", debian_version="stretch", revision="master", domain="localhost:4242"): + + https = False + if domain.split(":")[0] not in ("localhost", "127.0.0.1", "0.0.0.0"): + https = True + + response = requests.post("http%s://%s/api/job" % ("s" if https else "", domain), json={ + "name": name, + "url_or_path": url_or_path, + "yunohost_version": yunohost_version, + "test_type": test_type, + "debian_version": debian_version, + "revision": revision, + }) + + assert response.content == b"ok", response.content + + +argh.dispatch_command(main) diff --git a/run.py b/run.py index 8b7e7ee..08b80e9 100644 --- a/run.py +++ b/run.py @@ -226,7 +226,7 @@ async def job_ws(request, websocket, job_id): await websocket.send(f"echo {data}") -@app.route("/api/jobs", methods=['POST']) +@app.route("/api/job", methods=['POST']) async def api_new_job(request): # TODO auth or some kind