forked from ScoDoc/ScoDoc
Améliore message d'erreur si logo manquant dans un PDF
This commit is contained in:
parent
f59308b863
commit
e32d7b1b4e
@ -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 <para> ... </para>
|
||||
"""
|
||||
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 <b>{filename}</b> 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(
|
||||
'<font color="red"><i>Erreur: format invalide{}</i></font>'.format(
|
||||
detail
|
||||
)
|
||||
),
|
||||
SU('<font color="red"><i>Erreur: format invalide</i></font>'),
|
||||
style,
|
||||
)
|
||||
]
|
||||
return result
|
||||
|
||||
|
||||
def bold_paras(L, tag="b", close=None):
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user