Commit 85d6f035 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Raise an error when the generation of the ODT file failed.

parent 34e49256
......@@ -633,6 +633,7 @@
'The <i>record id</i> is not well formed.': 'Le <i>record id</i> est mal formé.',
'The category is used twice !': 'La catégorie est utilisée deux fois !',
'The field "%s" is missing ...': 'Le champ "%s" est manquant ...',
'The generation of the ODT file failed:<br><br>': 'La génération du fichier ODT a échoué :<br><br>',
'The generation of the PDF file failed.<br>Please, check the LaTeX file.': 'La génération du fichier PDF a échoué.<br>Vérifier le fichier LaTeX...',
'The graph can be rendered as line or stacked chart. The latter is used when the stacked fields are defined. ': 'The graph can be rendered as line or stacked chart. The latter is used when the stacked fields are defined. ',
'The identifier of the record in the invenio store': 'The identifier of the record in the invenio store',
......
......@@ -37,16 +37,28 @@
#
# convert the HTML in ODT file
#
fi_tmp = TemporaryFile()
cmd = ["libreoffice", "--headless", "--convert-to", "odt", fhtml]
call(cmd, stdout=TemporaryFile())
call(cmd, stdout=fi_tmp)
fodt = '%s.odt' % froot
fi = open(fodt, 'rb')
sodt = fi.read()
fi.close()
if os.path.exists(fodt):
fi = open(fodt, 'rb')
sodt = fi.read()
fi.close()
s64 = base64.b64encode(sodt)
else:
call("rm -f %s.*" % froot, shell=True)
os.chdir(cwd)
fi_tmp.seek(0)
msg = T("The generation of the ODT file failed:<br><br>")
msg += fi_tmp.read()
fi_tmp.close()
raise HTTP(500, msg)
pass
#
# clean
......@@ -68,5 +80,6 @@
response.headers['Content-Type']='application/vnd.oasis.opendocument.text'
response.headers['Content-Disposition'] = 'attachment;filename="list.odt"'
s64 = base64.b64encode(sodt)
response.write(s64, escape=False)
}}
\ No newline at end of file
Markdown is supported
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