From 29779f1a680b8731fd4a5676829a77dafc6a4f8d Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sun, 20 Jan 2019 07:12:55 +0100 Subject: [PATCH] [enh] new app-list ciclic command --- README.md | 6 ++++++ ciclic | 13 ++++++++++++- run.py | 8 ++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a45d8a6..71f5547 100644 --- a/README.md +++ b/README.md @@ -160,6 +160,12 @@ Note that delete/restart will stop the job first to free the worker. You will see a resulting log on the server for each action. +List apps: + +``` +$ ve3/bin/python ciclic app-list +``` + # Deployment You need to put this program behind a nginx mod proxy AND add the magical lines diff --git a/ciclic b/ciclic index 2779360..1b44a7c 100644 --- a/ciclic +++ b/ciclic @@ -79,6 +79,17 @@ def list_(all=False, domain=DOMAIN): print(f"{i['id']:4d} - {i['name']} [{i['state']}]") +def app_list(all=False, domain=DOMAIN): + response = request_api( + path="app", + verb="get", + domain=domain, + ) + + for i in response.json(): + print(f"{i['name']} - {i['url']}") + + def delete(job_id, domain=DOMAIN): response = request_api( path=f"job/{job_id}", @@ -126,4 +137,4 @@ def restart(job_id, domain=DOMAIN): if __name__ == '__main__': require_token() - argh.dispatch_commands([add, list_, delete, stop, restart]) + argh.dispatch_commands([add, list_, delete, stop, restart, app_list]) diff --git a/run.py b/run.py index e89a0b5..6ed42c7 100644 --- a/run.py +++ b/run.py @@ -617,6 +617,14 @@ async def api_list_job(request): return response.json([model_to_dict(x) for x in query.order_by(-Job.id)]) +@app.route("/api/app", methods=['GET']) +@require_token() +async def api_list_app(request): + query = Repo.select() + + return response.json([model_to_dict(x) for x in query.order_by(-Repo.name)]) + + @app.route("/api/job/", methods=['DELETE']) @require_token() async def api_delete_job(request, job_id):