Borrar archivos temporales

This commit is contained in:
Mauricio Baeza 2018-02-08 22:24:32 -06:00
parent 3c76d3a55f
commit 5c3fb3e30f
1 changed files with 10 additions and 11 deletions

View File

@ -1061,24 +1061,23 @@ class LIBO(object):
self._template.setPrinter(self._set_properties({'PaperFormat': LETTER}))
self._render(data)
# ~ path = '{}.ods'.format(tempfile.mkstemp()[1])
path = get_path_temp('.ods')
self._template.storeToURL(self._path_url(path), ())
path_ods = get_path_temp('.ods')
self._template.storeToURL(self._path_url(path_ods), ())
if ods:
data = self._read(path)
_kill(path)
data = self._read(path_ods)
_kill(path_ods)
return data
doc = self._doc_open(path, {'Hidden': True})
doc = self._doc_open(path_ods, {'Hidden': True})
options = {'FilterName': 'calc_pdf_Export'}
# ~ path = tempfile.mkstemp()[1]
path = get_path_temp('.pdf')
doc.storeToURL(self._path_url(path), self._set_properties(options))
path_pdf = get_path_temp('.pdf')
doc.storeToURL(self._path_url(path_pdf), self._set_properties(options))
doc.close(True)
self._template.close(True)
data = self._read(path)
_kill(path)
data = self._read(path_pdf)
_kill(path_ods)
_kill(path_pdf)
return data
def _get_data(self, doc, name=0):