Catch exceptions from failed ps2edit calls

This commit is contained in:
Florian Festi 2019-08-15 23:05:21 +02:00
parent c81d23e605
commit 02988d12c5
2 changed files with 15 additions and 5 deletions

View File

@ -113,6 +113,10 @@ class Formats:
if err:
# XXX show stderr output
try:
os.unlink(tmpfile)
except:
pass
raise ValueError("Conversion failed. pstoedit returned %i" % err)
os.rename(tmpfile, filename)

View File

@ -411,15 +411,21 @@ b"""
start_response(status, headers)
return self.errorMessage(name, e)
start_response(status,
box.formats.http_headers.get(
box.format,
[('Content-type', 'application/unknown; charset=utf-8')]))
fd, box.output = tempfile.mkstemp()
box.metadata["url"] = self.getURL(environ)
box.open()
box.render()
box.close()
try:
box.close()
except ValueError as e:
start_response("500 Internal Server Error",
[('Content-type', 'text/plain; charset=utf-8')])
return([b"Server Error\n\n", str(e).encode("utf-8")])
start_response(status,
box.formats.http_headers.get(
box.format,
[('Content-type', 'application/unknown; charset=utf-8')]))
result = open(box.output).readlines()
os.close(fd)
os.remove(box.output)