diff --git a/resolved_task.py b/resolved_task.py index 0d934a1..b67d2a5 100644 --- a/resolved_task.py +++ b/resolved_task.py @@ -37,36 +37,38 @@ def close_tasks_in_queue(queue_name): } } - response = requests.post( - base_url, - headers=headers, - data=json.dumps(payload) - ) + while True: - if response.status_code == 200: - logger.debug('Response: %s', response.content) + response = requests.post( + base_url, + headers=headers, + data=json.dumps(payload) + ) - tasks = response.json() + if response.status_code == 200: + logger.debug('Response: %s', response.content) - for task in tasks: - task_id = task['id'] - close_payload = { - 'resolution': 'fixed' - } - close_url = f'https://api.tracker.yandex.net/v2/issues/{task_id}/transitions/close/_execute' - print(close_url) - print(headers) - close_response = requests.post( - close_url, - headers=headers, - data=json.dumps(close_payload) - ) - if close_response.status_code == 200: - print(f'Задача {task_id} закрыта успешно') - else: - print(f'Ошибка при закрытии задачи {task_id}: {close_response.content}') - else: - print(f'Ошибка при получении задач для очереди {queue_name}: {response.content}') + tasks = response.json() + + for task in tasks: + task_id = task['id'] + close_payload = { + 'resolution': 'fixed' + } + close_url = f'https://api.tracker.yandex.net/v2/issues/{task_id}/transitions/close/_execute' + print(close_url) + print(headers) + close_response = requests.post( + close_url, + headers=headers, + data=json.dumps(close_payload) + ) + if close_response.status_code == 200: + print(f'Задача {task_id} закрыта успешно') + else: + print(f'Ошибка при закрытии задачи {task_id}: {close_response.content}') + else: + print(f'Ошибка при получении задач для очереди {queue_name}: {response.content}') # Вызов функции для закрытия задач в очереди 'TESTIMPORT'