Skip to content

Commit

Permalink
appel le script d'import des contacts
Browse files Browse the repository at this point in the history
  • Loading branch information
alanzirek committed Feb 28, 2025
1 parent 3a0f45d commit 18fc1d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import tempfile

from django.conf import settings
from django.core.management import call_command
from django.core.management.base import BaseCommand
import paramiko

Expand Down Expand Up @@ -216,11 +217,14 @@ def handle(self, *args, **options):
symmetric_key_file_path = self.decrypt_symmetric_key(
private_key_data, encrypted_symmetric_key_file_path, settings.BASE_DIR
)
self.decrypt_data_file(encrypt_data_file_path, symmetric_key_file_path, settings.BASE_DIR)
decrypted_file_path = self.decrypt_data_file(
encrypt_data_file_path, symmetric_key_file_path, settings.BASE_DIR
)
os.remove(encrypted_symmetric_key_file_path)
os.remove(symmetric_key_file_path)
os.remove(encrypt_data_file_path)
# TODO: remove le fichier de données déchiffré après utilisation
call_command("import_contacts", decrypted_file_path)
os.remove(decrypted_file_path)
except Exception as e:
self.stdout.write(self.style.ERROR(f"Erreur : {str(e)}"))
finally:
Expand Down
1 change: 1 addition & 0 deletions core/management/commands/import_contacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def save_contact(self, row, ligne):
raise Exception(f"Erreur lors de l'importation à la ligne {ligne} : {e}")

def handle(self, *args, **kwargs):
self.stdout.write("Début de l'importation...")
start_time = time.time()
csv_file_path = kwargs["csv_file"]
ligne = 1
Expand Down

0 comments on commit 18fc1d7

Please sign in to comment.