Commit 4677401b authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Tune views/reports/report_2.pdf (but not working yet).

parent cb5d7ad4
......@@ -2,7 +2,7 @@
{{
import base64
import cStringIO
import io
import os
from subprocess import call
......@@ -12,14 +12,14 @@ from uuid import uuid4
# recuperate the latex string generate by the latex view
# and remove it from the response object
latex = response.body.getvalue()
response.body = cStringIO.StringIO()
response.body = io.StringIO()
# go to the private directory and create a latex file
cwd = os.getcwd()
os.chdir(os.path.join(request.folder, 'private'))
fn = str(uuid4())
fi = open('%s.tex' % fn, 'wb')
fi = open('%s.tex' % fn, 'w')
fi.write(latex)
fi.close()
......@@ -35,7 +35,7 @@ fi.close()
s64 = base64.b64encode(spdf)
# clean files
for ext in ('aux', 'log', 'pdf', 'tex'):
for ext in ('aux', 'log', 'out', 'pdf', 'tex'):
f = '%s.%s' % (fn, ext)
if os.path.exists(f):
os.remove(f)
......@@ -46,6 +46,7 @@ pass
os.chdir(cwd)
# build the response
response.body = io.StringIO()
response.headers['Content-Type']='application/pdf'
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