diff --git a/logging_config.py b/logging_config.py index 722b295..9ad6fba 100644 --- a/logging_config.py +++ b/logging_config.py @@ -17,7 +17,8 @@ def setup_logging(name): file_handler = logging.FileHandler( filename=f"{name}.log", mode='w', - encoding='utf-8' + encoding='utf-8', + delay=True ) file_handler.setLevel(logging.DEBUG) diff --git a/mapping.py b/mapping.py index 2958d74..301e374 100644 --- a/mapping.py +++ b/mapping.py @@ -131,6 +131,9 @@ def create_tasks_in_tracker(data): parent_task_gid = task['parent']['gid'] if parent_task_gid in ya_imported_task_response: parent_task_id = ya_imported_task_response[parent_task_gid]['id'] + logger.debag( + f'В задаче {task['summary']} есть связка "parent"' + ) update_parent_task( base_url, headers, @@ -145,9 +148,19 @@ def update_parent_task(base_url, headers, task_id, parent_task_id): payload = { 'parent': parent_task_id } - update_url = f"{base_url}/{task_id}" + try: + response = requests.post(update_url, headers=headers, data=payload) + + if response.status_code == 200: + print('Данные успешно обновлены с добавлением нового элемента.') + else: + print('Ошибка при обновлении данных.') + + except requests.exceptions.RequestException as error: + print('Произошла ошибка при обновлении данных:', error) + # asana_data = get_data_from_asana() file = open(asana_data_json, "r", encoding="utf8")