Commit 0f20ef37 authored by Christophe Benz's avatar Christophe Benz
Browse files

On PDF error, don't display system error, redirect to schema page

parent 4710cd29
......@@ -265,16 +265,16 @@ def validators():
def pdf_report(val_code):
"""PDF report generation"""
err_prefix = 'Erreur de génération du rapport PDF: '
err_prefix = 'Erreur de génération du rapport PDF'
if not ValidatorHelper.schema_exist(val_code):
flash_error(err_prefix + 'schéma inconnu')
return redirect(url_for('home'))
flash_error(err_prefix + ': schéma inconnu')
return redirect(url_for('scdl_validator', val_code=val_code))
url_param = request.args.get('url')
if not url_param:
flash_error(err_prefix+'url non fournie')
return redirect(url_for('home'))
flash_error(err_prefix + ': URL non fournie')
return redirect(url_for('scdl_validator', val_code=val_code))
validation_url = '{}?input=url&print=true&url={}'.format(url_for('scdl_validator', val_code=val_code, _external=True),
......@@ -286,10 +286,11 @@ def pdf_report(val_code):
'--print-to-pdf={}'.format(str(tmp_pdf_report)), validation_url]
result =, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
if result.returncode != 0:
flash_error(err_prefix + result.stdout)
log.error("Command %r returned an error: %r", cmd, result.stdout.decode('utf-8'))
if tmp_pdf_report.exists():
return redirect(url_for('home'))
return redirect(url_for('scdl_validator', val_code=val_code))
response = make_response('rb').read())
response.headers.set('Content-disposition', 'attachment', filename='report.pdf')
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment