[reportlab-users] Intermittent failure to find font, followed by IOError
Stevens, Ian
IStevens at globeandmail.com
Mon Jan 19 15:53:04 EST 2009
We've got a weird issue on our production boxes and I'm hoping someone
might be able to shed some light. We're using Reportlab with Django to
serve PDFs over HTTP. Any fonts which may be required are loaded before
a PDF is built from Flowables. However, occasionally Reportlab appears
to think a font isn't loaded, will execute a brute search for the
required font and then fail when reading in one of Reportlab's stock
fonts. The font in question is reportlab/fonts/LeERC___.AFM.
This error is intermittent, which is bothersome, and always occurs from
the same line, executed within a PageTemplate's onPage() method. Here's
a stacktrace of the error:
==
File
"/usr/lib/python2.5/site-packages/Django-0.97_pre-py2.5.egg/django/core/
handlers/base.py", line 82, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/prod/prod-00/django/fundprofile/agf/fund.py", line 137, in pdf
template.build(fund)
File "/prod/prod-00/django/fundprofile/agf/templates/template.py",
line 762, in build
return BaseDocTemplate.build(self, fundPortfolio)
File
"/usr/lib/python2.5/site-packages/reportlab/platypus/doctemplate.py",
line 737, in build
self.clean_hanging()
File
"/usr/lib/python2.5/site-packages/reportlab/platypus/doctemplate.py",
line 396, in clean_hanging
self.handle_flowable(self._hanging)
File
"/usr/lib/python2.5/site-packages/reportlab/platypus/doctemplate.py",
line 633, in handle_flowable
f.apply(self)
File
"/usr/lib/python2.5/site-packages/reportlab/platypus/doctemplate.py",
line 114, in apply
getattr(doc,arn)(*args)
File
"/usr/lib/python2.5/site-packages/reportlab/platypus/doctemplate.py",
line 421, in handle_pageBegin
self.pageTemplate.onPage(self.canv,self)
File "/prod/prod-00/django/app/template.py", line 24, in
drawPage1Layout
doc.drawPageLayout(canvas, "PAGE_ONE")
File "/prod/prod-00/django/app/template.py", line 114, in
drawPageLayout
layout.drawFooterText(canvas)
File "/prod/prod-00/django/app/components/layout.py", line 124, in
drawFooterText
canvas.setFont("ScalaSansRegular", 8)
File "/usr/lib/python2.5/site-packages/reportlab/pdfgen/canvas.py",
line 1302, in setFont
font = pdfmetrics.getFont(self._fontname)
File
"/usr/lib/python2.5/site-packages/reportlab/pdfbase/pdfmetrics.py", line
658, in findFontAndRegister
face = getTypeFace(fontName)
File
"/usr/lib/python2.5/site-packages/reportlab/pdfbase/pdfmetrics.py", line
629, in getTypeFace
afm = bruteForceSearchForAFM(faceName)
File
"/usr/lib/python2.5/site-packages/reportlab/pdfbase/pdfmetrics.py", line
227, in bruteForceSearchForAFM
(topDict, glyphDict) = parseAFMFile(possible)
File
"/usr/lib/python2.5/site-packages/reportlab/pdfbase/pdfmetrics.py", line
80, in parseAFMFile
lines = open_and_readlines(afmFileName, 'r')
File "/usr/lib/python2.5/site-packages/reportlab/lib/utils.py", line
452, in open_and_readlines
return open_and_read(name,mode).split('\n')
File "/usr/lib/python2.5/site-packages/reportlab/lib/utils.py", line
449, in open_and_read
return open_for_read(name,mode).read()
File "/usr/lib/python2.5/site-packages/reportlab/lib/utils.py", line
445, in open_for_read
raise IOError('Cannot open resource "%s"' % name)
IOError: Cannot open resource
"/usr/lib/python2.5/site-packages/reportlab/fonts/LeERC___.AFM"
==
If it helps, all Python libraries are local while the Django app code is
on a shared drive. We're using Apache 2.2 with mod_python 3.3.1 on
Ubuntu.
Any ideas would be extremely helpful.
thanks,
Ian.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20090119/3730a663/attachment.htm>
More information about the reportlab-users
mailing list