From eb0c8436849460e02f82e260ee7cdfd1823de447 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Mon, 18 Dec 2023 16:37:29 +0100 Subject: [PATCH] Fix error display. Add sleep --- .../siaes/management/commands/sync_with_emplois_inclusion.py | 2 +- lemarche/stats/management/commands/import_users_for_stats.py | 2 +- lemarche/utils/apis/api_emplois_inclusion.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lemarche/siaes/management/commands/sync_with_emplois_inclusion.py b/lemarche/siaes/management/commands/sync_with_emplois_inclusion.py index c74639b35..6c711c839 100644 --- a/lemarche/siaes/management/commands/sync_with_emplois_inclusion.py +++ b/lemarche/siaes/management/commands/sync_with_emplois_inclusion.py @@ -211,7 +211,7 @@ def c1_export(self): # noqa C901 return c1_list_cleaned except Exception as e: api_slack.send_message_to_channel("Erreur lors de la synchronisation emplois <-> marché") - self.stdout_error(e) + self.stdout_error(str(e)) raise Exception(e) def filter_c1_export(self, c1_list): diff --git a/lemarche/stats/management/commands/import_users_for_stats.py b/lemarche/stats/management/commands/import_users_for_stats.py index 9c0c2b0e2..bd0562757 100644 --- a/lemarche/stats/management/commands/import_users_for_stats.py +++ b/lemarche/stats/management/commands/import_users_for_stats.py @@ -55,7 +55,7 @@ def upload_users_to_db_stats(self, users_list): try: return StatsUser.objects.bulk_create(stats_users_list, batch_size=50) except IntegrityError as e: - self.stdout_error(e) + self.stdout_error(str(e)) def clean_stats_users(self): count_delete, _ = StatsUser.objects.all().delete() diff --git a/lemarche/utils/apis/api_emplois_inclusion.py b/lemarche/utils/apis/api_emplois_inclusion.py index 3c1cbe9f1..fa8aa4a01 100644 --- a/lemarche/utils/apis/api_emplois_inclusion.py +++ b/lemarche/utils/apis/api_emplois_inclusion.py @@ -1,4 +1,5 @@ import logging +import time import requests from django.conf import settings @@ -26,6 +27,7 @@ def get_siae_list(): siae_list.append(siae) if data["next"]: pagination += 1 + time.sleep(1) else: break