From 5f49355ec338680948896713cb5a94f451e4af20 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Fri, 22 Dec 2023 15:24:53 +0100 Subject: [PATCH] logs et exceptions --- app/scodoc/sco_archives_justificatifs.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/scodoc/sco_archives_justificatifs.py b/app/scodoc/sco_archives_justificatifs.py index b3564b8b..f2a50a19 100644 --- a/app/scodoc/sco_archives_justificatifs.py +++ b/app/scodoc/sco_archives_justificatifs.py @@ -157,15 +157,15 @@ class JustificatifArchiver(BaseArchiver): Si trace == True : sauvegarde le nom du/des fichier(s) supprimé(s) dans la trace de l'étudiant """ - print("debug : ", archive_name, filename, has_trace) + log(f"debug : {archive_name}{filename} {has_trace}") if str(etud.id) not in self.list_oids(etud.dept_id): raise ValueError(f"Aucune archive pour etudid[{etud.id}]") try: archive_id = self.get_id_from_name( etud.id, archive_name, dept_id=etud.dept_id ) - except ScoValueError: - raise ValueError(f"Archive Inconnue [{archive_name}]") + except ScoValueError as exc: + raise ValueError(f"Archive Inconnue [{archive_name}]") from exc if filename is not None: if filename not in self.list_archive(archive_id, dept_id=etud.dept_id): @@ -183,6 +183,7 @@ class JustificatifArchiver(BaseArchiver): trace = Trace(archive_id) trace.set_trace(filename, mode="delete") os.remove(path) + log(f"delete_justificatif: removed {path}") else: if has_trace: @@ -197,6 +198,7 @@ class JustificatifArchiver(BaseArchiver): archive_id, ) ) + log(f"delete_justificatif: deleted archive {archive_id}") def list_justificatifs( self, archive_name: str, etud: Identite