# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
#
+from errno import ENOENT
import os
import os.path
-import shutil
-import subprocess
-from tempfile import mkdtemp
-from StringIO import StringIO
from django.conf import settings
import logging
from django.http import HttpResponse
-from django.template.loader import render_to_string
logger = logging.getLogger(__name__)
:param dict add_files: a dictionary of additional files XeTeX will need
"""
+ from StringIO import StringIO
+ import shutil
+ from tempfile import mkdtemp
+ import subprocess
import Texml.processor
+ from django.template.loader import render_to_string
+
rendered = render_to_string(template, context)
texml = StringIO(rendered.encode('utf-8'))
tempdir = mkdtemp(prefix = "render_to_pdf-")
send_name = os.path.basename(file_name)
def signal_handler(*args, **kwargs):
- os.unlink(file_path)
+ try:
+ os.unlink(file_path)
+ except OSError as oe:
+ if oe.errno != ENOENT:
+ raise oe
if signals:
for signal in signals: