diff --git a/app/scodoc/sco_pdf.py b/app/scodoc/sco_pdf.py
index 2a97e716..40546e75 100755
--- a/app/scodoc/sco_pdf.py
+++ b/app/scodoc/sco_pdf.py
@@ -66,7 +66,7 @@ from app.scodoc.sco_utils import (
LOGOS_IMAGES_ALLOWED_TYPES,
)
from app import log
-from app.scodoc.sco_exceptions import ScoGenError
+from app.scodoc.sco_exceptions import ScoGenError, ScoValueError
import sco_version
PAGE_HEIGHT = defaultPageSize[1]
@@ -121,6 +121,7 @@ def makeParas(txt, style, suppress_empty=False):
"""Returns a list of Paragraph instances from a text
with one or more ...
"""
+ result = []
try:
paras = _splitPara(txt)
if suppress_empty:
@@ -133,21 +134,31 @@ def makeParas(txt, style, suppress_empty=False):
if m.group(1): # non empty paragraph
r.append(para)
paras = r
- return [Paragraph(SU(s), style) for s in paras]
+ result = [Paragraph(SU(s), style) for s in paras]
+ except OSError as e:
+ msg = str(e)
+ # If a file is missing, try to display the invalid name
+ m = re.match(r".*\sfilename=\'(.*?)\'.*", msg, re.DOTALL)
+ if m:
+ filename = os.path.split(m.group(1))[1]
+ if filename.startswith("logo_"):
+ filename = filename[len("logo_") :]
+ raise ScoValueError(
+ f"Erreur dans le format PDF paramétré: fichier logo {filename} non trouvé"
+ ) from e
+ else:
+ raise e
except Exception as e:
detail = " " + str(e)
log(traceback.format_exc())
log("Invalid pdf para format: %s" % txt)
- return [
+ result = [
Paragraph(
- SU(
- 'Erreur: format invalide{}'.format(
- detail
- )
- ),
+ SU('Erreur: format invalide'),
style,
)
]
+ return result
def bold_paras(L, tag="b", close=None):
diff --git a/app/views/__init__.py b/app/views/__init__.py
index 1c20f46c..a2dae02f 100644
--- a/app/views/__init__.py
+++ b/app/views/__init__.py
@@ -25,7 +25,7 @@ from app.views import scodoc, notes, scolar, absences, users
@scodoc_bp.before_app_request
def start_scodoc_request():
"""Affecte toutes les requêtes, de tous les blueprints"""
- current_app.logger.info(f"start_scodoc_request")
+ # current_app.logger.info(f"start_scodoc_request")
ndb.open_db_connection()
if current_user.is_authenticated:
current_user.last_seen = datetime.datetime.utcnow()