dump fichier en erreur pour debug

This commit is contained in:
Emmanuel Viennet 2021-09-28 07:22:23 +02:00
parent 550a7888bf
commit f5529ec4a6
1 changed files with 13 additions and 8 deletions

View File

@ -567,23 +567,27 @@ def excel_bytes_to_list(bytes_content):
filelike = io.BytesIO(bytes_content)
return _excel_to_list(filelike)
except:
raise ScoValueError("""
raise ScoValueError(
"""
scolars_import_excel_file: un contenu xlsx semble corrompu!
peut-être avez vous fourni un fichier au mauvais format (txt, xls, ..)
""")
"""
)
def excel_file_to_list(filename):
try:
return _excel_to_list(filename)
except:
raise ScoValueError("""
scolars_import_excel_file: un contenu xlsx semble corrompu!
peut-être avez vous fourni un fichier au mauvais format (txt, xls, ..)
""")
raise ScoValueError(
"""scolars_import_excel_file: un contenu xlsx
semble corrompu !
Peut-être avez-vous fourni un fichier au mauvais format (txt, xls, ...)
"""
)
def _excel_to_list(filelike): # we may need 'encoding' argument ?
def _excel_to_list(filelike):
"""returns list of list
convert_to_string is a conversion function applied to all non-string values (ie numbers)
"""
@ -591,7 +595,8 @@ def _excel_to_list(filelike): # we may need 'encoding' argument ?
wb = load_workbook(filename=filelike, read_only=True, data_only=True)
except:
log("Excel_to_list: failure to import document")
open("/tmp/last_scodoc_import_failure" + scu.XLSX_SUFFIX, "wb").write(filelike)
with open("/tmp/last_scodoc_import_failure" + scu.XLSX_SUFFIX, "wb") as f:
f.write(filelike)
raise ScoValueError(
"Fichier illisible: assurez-vous qu'il s'agit bien d'un document Excel !"
)