5386: libhtmlbackend.py crashes if a dir-name file preexists
svn: r18531
This commit is contained in:
parent
ab86ffd40e
commit
fb48820056
@ -38,6 +38,7 @@ import sys
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import libcairodoc
|
||||
import Errors
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -86,7 +87,13 @@ class PdfDoc(libcairodoc.CairoDoc):
|
||||
|
||||
# create cairo context and pango layout
|
||||
filename = self._backend.filename.encode(sys.getfilesystemencoding())
|
||||
surface = cairo.PDFSurface(filename, paper_width, paper_height)
|
||||
try:
|
||||
surface = cairo.PDFSurface(filename, paper_width, paper_height)
|
||||
except IOError,msg:
|
||||
errmsg = "%s\n%s" % (_("Could not create %s") % filename, msg)
|
||||
raise Errors.ReportError(errmsg)
|
||||
except:
|
||||
raise Errors.ReportError(_("Could not create %s") % filename)
|
||||
surface.set_fallback_resolution(300, 300)
|
||||
cr = pangocairo.CairoContext(cairo.Context(surface))
|
||||
|
||||
|
@ -45,6 +45,7 @@ import os.path
|
||||
from gen.plug.docbackend import DocBackend
|
||||
from libhtml import Html
|
||||
from Utils import xml_lang
|
||||
import Errors
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@ -242,9 +243,25 @@ class HtmlBackend(DocBackend):
|
||||
overwrite method, htmlbackend creates a html object that is written on
|
||||
close
|
||||
"""
|
||||
DocBackend.open(self)
|
||||
try:
|
||||
DocBackend.open(self)
|
||||
except IOError,msg:
|
||||
errmsg = "%s\n%s" % (_("Could not create %s") %
|
||||
self._filename, msg)
|
||||
raise Errors.ReportError(errmsg)
|
||||
except:
|
||||
raise Errors.ReportError(_("Could not create %s") %
|
||||
self._filename)
|
||||
if not os.path.isdir(self.datadirfull()):
|
||||
os.mkdir(self.datadirfull())
|
||||
try:
|
||||
os.mkdir(self.datadirfull())
|
||||
except IOError,msg:
|
||||
errmsg = "%s\n%s" % (_("Could not create %s") %
|
||||
self.datadirfull(), msg)
|
||||
raise Errors.ReportError(errmsg)
|
||||
except:
|
||||
raise Errors.ReportError(_("Could not create %s") %
|
||||
self.datadirfull())
|
||||
self.html_page, self.html_header, self.html_body = Html.page(
|
||||
lang=xml_lang(), title=self.title)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user