From 43194a962bc28a109c462a8ab065cc4e1a2dbdaf Mon Sep 17 00:00:00 2001 From: Felipe Signorini Date: Sun, 30 Dec 2018 01:44:42 -0200 Subject: [PATCH] disable schedule when the connection raise error --- app/tasks/connections.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/tasks/connections.py b/app/tasks/connections.py index f03c4b4..06388a5 100644 --- a/app/tasks/connections.py +++ b/app/tasks/connections.py @@ -38,9 +38,13 @@ def task_connections(name, _id, endpoint, source='discovery', method="GET", args if resource.get_status() < 400: result = resource.get_results() - msg = "Connection success - %s" % conn_id + if result.get('found', 0) == 1: webhook_id = task_webhook.delay(name, _id, endpoint, source, method, args, chain) return {'webhook_id': webhook_id} + else: + msg = "Connection issue - %s" % conn_id + task_deplete.delay(msg, _id) + return {'msg': msg, 'status_code': resource.get_status()} \ No newline at end of file