Commit ede363ec authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Improved logic for ODT conversion.

parent 08ca38d4
......@@ -406,6 +406,7 @@
'Number of records validated: %s': "Nombre d'enregistrements validé : %s",
'Number(s)': 'Numéro(s)',
'Object or table name': 'Object or table name',
'ODT conversion requires an X11 server.': "La conversion ODT a besoin d'un serveur X11.",
'Ok': 'Ok',
'Old password': 'Old password',
'Open source': 'Code open source',
......@@ -35,22 +35,24 @@
# convert the HTML in ODT file using libreoffice
# convert the HTML in ODT file using LibreOffice
# LibreOffice require a (virtual) X11 server
fi_tmp = TemporaryFile()
if "DISPLAY" not in os.environ:
# create the virtual X11 environment on the server
if os.path.exists('/usr/bin/Xvfb'):
cmd = "Xvfb :1 -screen 0 800x600x8 & "
cmd += "libreoffice --nologo --headless --invisible --display :1.0 --convert-to odt "
cmd += fhtml
cmd = ["libreoffice",
"--display", os.environ["DISPLAY"],
"--convert-to", "odt", fhtml]
call(cmd, stdout=fi_tmp, shell=True)
call(cmd, stdout=fi_tmp)
# development area in which X11 is running
cmd = ["libreoffice", "--headless", "--convert-to", "odt", fhtml]
call(cmd, stdout=fi_tmp)
msg = T("ODT conversion requires an X11 server.")
raise HTTP(500, msg)
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