Opened 14 years ago
Last modified 12 years ago
#8916 new defect
ZeroDivisionError: float division (can't install with easy_install)
Reported by: | Nvt | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | high | Component: | TracWikiPrintPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: | 0.11 |
Description
Hi.. I'm a newbie.. I got this error if i select multiple pages into pdf book or article. Can you help me? Thanks alot.
Oops… Trac detected an internal error: ZeroDivisionError: float division
Python Traceback Most recent call last: * File "/usr/local/lib/python2.6/dist-packages/Trac-0.12.2-py2.6.egg/trac/web/main.py", line 511, in _dispatch_request Code fragment: Line 506 try: 507 if not env and env_error: 508 raise HTTPInternalError(env_error) 509 try: 510 dispatcher = RequestDispatcher(env) 511 dispatcher.dispatch(req) 512 except RequestDone: 513 pass 514 resp = req._response or [] 515 516 except HTTPException, e: Local variables: Name Value dispatcher <trac.web.main.RequestDispatcher object at 0x9789f0c> e ZeroDivisionError('float division',) env <trac.env.Environment object at 0x9410a0c> env_error None req <Request "POST '/admin/wikiprint/makebook'"> resp [] * File "/usr/local/lib/python2.6/dist-packages/Trac-0.12.2-py2.6.egg/trac/web/main.py", line 237, in dispatch Code fragment: Line 232 msg = _('Do you have cookies enabled?') 233 raise HTTPBadRequest(_('Missing or invalid form token.' 234 ' %(msg)s', msg=msg)) 235 236 # Process the request and render the template 237 resp = chosen_handler.process_request(req) 238 if resp: 239 if len(resp) == 2: # Clearsilver 240 chrome.populate_hdf(req) 241 template, content_type = \ 242 self._post_process_request(req, *resp) Local variables: Name Value chosen_handler <trac.admin.web_ui.AdminModule object at 0x9789dcc> chrome <trac.web.chrome.Chrome object at 0x96c410c> ctype 'application/x-www-form-urlencoded' err (<type 'exceptions.ZeroDivisionError'>, ZeroDivisionError('float ... handler <trac.admin.web_ui.AdminModule object at 0x9789dcc> options {} req <Request "POST '/admin/wikiprint/makebook'"> self <trac.web.main.RequestDispatcher object at 0x9789f0c> * File "/usr/local/lib/python2.6/dist-packages/Trac-0.12.2-py2.6.egg/trac/admin/web_ui.py", line 116, in process_request Code fragment: Line 111 if not provider: 112 raise HTTPNotFound(_('Unknown administration panel')) 113 114 if hasattr(provider, 'render_admin_panel'): 115 template, data = provider.render_admin_panel(req, cat_id, panel_id, 116 path_info) 117 118 else: # support for legacy WebAdmin panels 119 data = {} 120 cstmpl, ct = provider.process_admin_request(req, cat_id, panel_id, 121 path_info) Local variables: Name Value _panel_order <function _panel_order at 0xa3cc95c> cat_id u'wikiprint' panel_id u'makebook' panels [('general', 'General', 'basics', 'Basic Settings'), ('general', ... path_info None provider <wikiprint.web_ui.WikiPrintAdmin object at 0x9743b8c> providers {('tracini', 'inherit'): <iniadmin.iniadmin.IniAdminPlugin object at ... req <Request "POST '/admin/wikiprint/makebook'"> self <trac.admin.web_ui.AdminModule object at 0x9789dcc> * File "/usr/local/lib/python2.6/dist-packages/TracWikiPrintPlugin-1.8.4-py2.6.egg/wikiprint/web_ui.py", line 53, in render_admin_panel Code fragment: Line 48 49 # IAdminPanelProvider methods 50 def render_admin_panel(self, req, cat, page, component): 51 52 if page == 'makebook': 53 return self._render_book(req, cat, page, component) 54 if page == 'options': 55 return self._render_options(req, cat, page, component) 56 57 58 def _render_book(self, req, cat, page, component): Local variables: Name Value cat u'wikiprint' component None page u'makebook' req <Request "POST '/admin/wikiprint/makebook'"> self <wikiprint.web_ui.WikiPrintAdmin object at 0x9743b8c> * File "/usr/local/lib/python2.6/dist-packages/TracWikiPrintPlugin-1.8.4-py2.6.egg/wikiprint/web_ui.py", line 88, in _render_book Code fragment: Line 83 84 if not format or format not in formats: 85 raise TracError('Bad format given for WikiPrint output.') 86 87 pdfbookname = title.replace(' ', '_').replace(':', '_').replace(',', '_') 88 return formats[format]['provider'].process_wikiprint(req, format, title, subject, rightpages, version, date, pdfbookname) 89 90 data['allpages'] = allpages 91 leftpages = [x for x in allpages if x not in rightpages] 92 leftpages.sort() 93 data['leftpages'] = leftpages Local variables: Name Value allpages [u'WikiNewPage', u'Projektphase/Erweiterungen/Makros', u'TracModWSGI', ... cat u'wikiprint' component None data {} date u'' format u'pdfarticle' formats {'pdfbook': {'name': 'PDF Book', 'provider': ... name 'HTML' page u'makebook' pdfbookname u'Projektphase' provider <wikiprint.formats.WikiPrintOutput object at 0xa24f1ac> req <Request "POST '/admin/wikiprint/makebook'"> rightpages [u'Inhaltsverzeichnis', u'Projektphase/Anforderungen', ... self <wikiprint.web_ui.WikiPrintAdmin object at 0x9743b8c> subject u'' title u'Projektphase' version u'' x '' * File "/usr/local/lib/python2.6/dist-packages/TracWikiPrintPlugin-1.8.4-py2.6.egg/wikiprint/formats.py", line 40, in process_wikiprint Code fragment: Line 35 36 if format == 'pdfbook': 37 out = wikiprint.html_to_pdf(req, html_pages, book=True, title=title, subject=subject, version=version, date=date) 38 req.send_header('Content-Disposition', 'attachment; filename=' + pdfname + '.pdf') 39 elif format == 'pdfarticle': 40 out = wikiprint.html_to_pdf(req, html_pages, book=False, title=title, subject=subject, version=version, date=date) 41 req.send_header('Content-Disposition', 'attachment; filename=' + pdfname + '.pdf') 42 elif format == 'printhtml': 43 out = wikiprint.html_to_printhtml(req, html_pages, title=title, subject=subject, version=version, date=date) 44 45 req.send_header('Content-Length', len(out)) Local variables: Name Value date u'' format u'pdfarticle' html_pages [<Markup u'<h1 id="MeinProjekt1">Mein Projekt 1</h1>\n<ul><li><a ... p u'Projektphase/Grundlagen' pages [u'Inhaltsverzeichnis', u'Projektphase/Anforderungen', ... pdfname u'Projektphase' req <Request "POST '/admin/wikiprint/makebook'"> self <wikiprint.formats.WikiPrintOutput object at 0xa24f1ac> subject u'' title u'Projektphase' version u'' wikiprint <wikiprint.wikiprint.WikiPrint object at 0x9743bcc> * File "/usr/local/lib/python2.6/dist-packages/TracWikiPrintPlugin-1.8.4-py2.6.egg/wikiprint/wikiprint.py", line 235, in html_to_pdf Code fragment: Line 230 cursor = db.cursor() 231 cursor.execute("INSERT INTO auth_cookie (cookie,name,ipnr,time) " 232 "VALUES (%s, %s, %s, %s)", (auth_cookie, req.authname, '127.0.0.1', int(time.time()))) 233 db.commit() 234 235 pdf = pisa.CreatePDF(page, pdf_file, show_errors_as_pdf = True, default_css = css_data, link_callback = loader.getFileName) 236 out = pdf_file.getvalue() 237 pdf_file.close() 238 239 cursor.execute("DELETE FROM auth_cookie WHERE cookie=%s", (auth_cookie,)) 240 db.commit() Local variables: Name Value auth_cookie 'f0636deb2cf166f318525a1f2fa4ae0e' book False css_data u'\nhtml {\n font-family: Helvetica; \n font-size: 10px; \n ... cursor <trac.db.util.IterableCursor object at 0xa21a92c> date u'' db <trac.db.pool.PooledConnection object at 0xa49f324> html_pages [<Markup u'<h1 id="MeinProjekt1">Mein Projekt 1</h1>\n<ul><li><a ... loader <wikiprint.wikiprint.linkLoader instance at 0xa7a52ec> page '<html><head><meta http-equiv="Content-Type" content="text/html; ... pdf_file <StringIO.StringIO instance at 0xa63096c> req <Request "POST '/admin/wikiprint/makebook'"> self <wikiprint.wikiprint.WikiPrint object at 0x9743bcc> subject u'' title u'Projektphase' version u'' * File "/usr/local/lib/python2.6/dist-packages/pisa-3.0.33-py2.6.egg/sx/pisa3/pisa_document.py", line 172, in pisaDocument Code fragment: Line 167 168 # Use multibuild e.g. if a TOC has to be created 169 if c.multiBuild: 170 doc.multiBuild(c.story) 171 else: 172 doc.build(c.story) 173 174 # Add watermarks 175 if pyPdf: 176 for bgouter in c.pisaBackgroundList: 177 Local variables: Name Value body <sx.pisa3.pisa_reportlab.PmlPageTemplate instance at 0x9f9f34c> c <sx.pisa3.pisa_context.pisaContext instance at 0xa21a94c> capacity 102400 debug 0 default_css u'\nhtml {\n font-family: Helvetica; \n font-size: 10px; \n ... dest <StringIO.StringIO instance at 0xa63096c> doc <sx.pisa3.pisa_reportlab.PmlBaseDoc instance at 0xa51478c> encoding None kw {'show_errors_as_pdf': True} link_callback <bound method linkLoader.getFileName of <wikiprint.wikiprint.linkLoader ... out <sx.pisa3.pisa_util.pisaTempFile object at 0xa63ad6c> path None raise_exception True show_error_as_pdf False src '<html><head><meta http-equiv="Content-Type" content="text/html; ... x '' xhtml False xml_output None * File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line 877, in build Code fragment: Line 872 canv._doctemplate = self 873 while len(flowables): 874 self.clean_hanging() 875 try: 876 first = flowables[0] 877 self.handle_flowable(flowables) 878 handled += 1 879 except: 880 #if it has trace info, add it to the traceback message. 881 if hasattr(first, '_traceInfo') and first._traceInfo: 882 exc = sys.exc_info()[1] Local variables: Name Value canv <reportlab.pdfgen.canvas.Canvas instance at 0xa51442c> canvasmaker <class reportlab.pdfgen.canvas.Canvas at 0x9a2a29c> filename None first PmlTable( rowHeights=[17.249999000000003, 17.249999000000003, ... flowableCount 169 flowables [PageBreak(), PmlParagraph( 'style' 'style' 'keepWithNext' ... handled 58 self <sx.pisa3.pisa_reportlab.PmlBaseDoc instance at 0xa51478c> * File "/usr/lib/python2.6/dist-packages/reportlab/platypus/doctemplate.py", line 762, in handle_flowable Code fragment: Line 757 self.afterFlowable(f) 758 else: 759 frame = self.frame 760 canv = self.canv 761 #try to fit it then draw it 762 if frame.add(f, canv, trySplit=self.allowSplitting): 763 if not isinstance(f,FrameActionFlowable): 764 self._curPageFlowableCount += 1 765 self.afterFlowable(f) 766 _addGeneratedContent(flowables,frame) 767 else: Local variables: Name Value canv <reportlab.pdfgen.canvas.Canvas instance at 0xa51442c> f PmlTable( rowHeights=[17.249999000000003, 17.249999000000003, ... flowables [PageBreak(), PmlParagraph( 'style' 'style' 'keepWithNext' ... frame <reportlab.platypus.frames.Frame instance at 0x9f9f58c> self <sx.pisa3.pisa_reportlab.PmlBaseDoc instance at 0xa51478c> * File "/usr/lib/python2.6/dist-packages/reportlab/platypus/frames.py", line 174, in _add Code fragment: Line 169 raise LayoutError("Flowable %s (%sx%s points) too large for frame (%sx%s points)." % ( 170 flowable.__class__, w,h, aW,self._aH)) 171 return 0 172 else: 173 #now we can draw it, and update the current point. 174 flowable.drawOn(canv, self._x + self._leftExtraIndent, y, _sW=aW-w) 175 flowable.canv=canv 176 if self._debug: logger.debug('drew %s' % flowable.identity()) 177 s = flowable.getSpaceAfter() 178 y -= s 179 if self._oASpace: self._prevASpace = s Local variables: Name Value a '_frame' aW 453.54330708661405 canv <reportlab.pdfgen.canvas.Canvas instance at 0xa51442c> flowable PmlTable( rowHeights=[17.249999000000003, 17.249999000000003, ... h 188.99999000000003 p 70.866141732283495 s 0 self <reportlab.platypus.frames.Frame instance at 0x9f9f58c> trySplit 1 w 453.54330708661405 y 439.77363604724394 * File "/usr/lib/python2.6/dist-packages/reportlab/platypus/flowables.py", line 106, in drawOn Code fragment: Line 101 def drawOn(self, canvas, x, y, _sW=0): 102 "Tell it to draw itself on the canvas. Do not override" 103 x = self._hAlignAdjust(x,_sW) 104 canvas.saveState() 105 canvas.translate(x, y) 106 self._drawOn(canvas) 107 if hasattr(self, '_showBoundary') and self._showBoundary: 108 #diagnostic tool support 109 canvas.setStrokeColor(gray) 110 canvas.rect(0,0,self.width, self.height) 111 canvas.restoreState() Local variables: Name Value _sW 0.0 canvas <reportlab.pdfgen.canvas.Canvas instance at 0xa51442c> self PmlTable( rowHeights=[17.249999000000003, 17.249999000000003, ... x 70.866141732283467 y 439.77363604724394 * File "/usr/lib/python2.6/dist-packages/reportlab/platypus/flowables.py", line 87, in _drawOn Code fragment: Line 82 self.encoding = None 83 84 def _drawOn(self,canv): 85 '''ensure canv is set on and then draw''' 86 self.canv = canv 87 self.draw()#this is the bit you overload 88 del self.canv 89 90 def _hAlignAdjust(self,x,sW=0): 91 if sW and hasattr(self,'hAlign'): 92 a = self.hAlign Local variables: Name Value canv <reportlab.pdfgen.canvas.Canvas instance at 0xa51442c> self PmlTable( rowHeights=[17.249999000000003, 17.249999000000003, ... * File "/usr/lib/python2.6/dist-packages/reportlab/platypus/tables.py", line 1272, in draw Code fragment: Line 1267 self._drawBkgrnd() 1268 if not self._spanCmds: 1269 # old fashioned case, no spanning, steam on and do each cell 1270 for row, rowstyle, rowpos, rowheight in zip(self._cellvalues, self._cellStyles, self._rowpositions[1:], self._rowHeights): 1271 for cellval, cellstyle, colpos, colwidth in zip(row, rowstyle, self._colpositions[:-1], self._colWidths): 1272 self._drawCell(cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)) 1273 else: 1274 # we have some row or col spans, need a more complex algorithm 1275 # to find the rect for each 1276 for rowNo in xrange(self._nrows): 1277 for colNo in xrange(self._ncols): Local variables: Name Value cellstyle <CellStyle1 '(8, 0)'> cellval <sx.pisa3.pisa_reportlab.PmlKeepInFrame instance at 0xa799d4c> colpos 0 colwidth 151.18110236220468 row [<sx.pisa3.pisa_reportlab.PmlKeepInFrame instance at 0xa799d4c>, ... rowheight 2.9999989999999999 rowpos 2.9999990000000087 rowstyle [<CellStyle1 '(8, 0)'>, <CellStyle1 '(8, 1)'>, <CellStyle1 '(8, 2)'>] self PmlTable( rowHeights=[17.249999000000003, 17.249999000000003, ... * File "/usr/lib/python2.6/dist-packages/reportlab/platypus/tables.py", line 1361, in _drawCell Code fragment: Line 1356 if isinstance(cellval,(tuple,list,Flowable)): 1357 if not isinstance(cellval,(tuple,list)): cellval = (cellval,) 1358 # we assume it's a list of Flowables 1359 W = [] 1360 H = [] 1361 w, h = self._listCellGeom(cellval,colwidth,cellstyle,W=W, H=H,aH=rowheight) 1362 if valign=='TOP': 1363 y = rowpos + rowheight - cellstyle.topPadding 1364 elif valign=='BOTTOM': 1365 y = rowpos+cellstyle.bottomPadding + h 1366 else: Local variables: Name Value .3 (0, 2.9999990000000087) .4 (151.18110236220468, 2.9999989999999999) H [] W [] cellstyle <CellStyle1 '(8, 0)'> cellval (<sx.pisa3.pisa_reportlab.PmlKeepInFrame instance at 0xa799d4c>,) colpos 0 colwidth 151.18110236220468 cur <CellStyle1 '(7, 2)'> just 'LEFT' rowheight 2.9999989999999999 rowpos 2.9999990000000087 self PmlTable( rowHeights=[17.249999000000003, 17.249999000000003, ... valign u'MIDDLE' * File "/usr/local/lib/python2.6/dist-packages/pisa-3.0.33-py2.6.egg/sx/pisa3/pisa_reportlab.py", line 637, in _listCellGeom Code fragment: Line 632 633 def _listCellGeom(self, V, w, s, W=None, H=None, aH=72000): 634 # print "#", self.availHeightValue 635 if aH == 72000: 636 aH = self.getMaxHeight() or aH 637 return Table._listCellGeom(self, V, w, s, W=W, H=H, aH=aH) 638 639 def wrap(self, availWidth, availHeight): 640 641 self.setMaxHeight(availHeight) 642 Local variables: Name Value H [] V (<sx.pisa3.pisa_reportlab.PmlKeepInFrame instance at 0xa799d4c>,) W [] aH 2.9999989999999999 s <CellStyle1 '(8, 0)'> self PmlTable( rowHeights=[17.249999000000003, 17.249999000000003, ... w 151.18110236220468 * File "/usr/lib/python2.6/dist-packages/reportlab/platypus/tables.py", line 366, in _listCellGeom Code fragment: Line 361 t = 0 362 w = 0 363 canv = getattr(self,'canv',None) 364 sb0 = None 365 for v in V: 366 vw, vh = v.wrapOn(canv, aW, aH) 367 sb = v.getSpaceBefore() 368 sa = v.getSpaceAfter() 369 if W is not None: W.append(vw) 370 if H is not None: H.append(vh) 371 w = max(w,vw) Local variables: Name Value H [] V (<sx.pisa3.pisa_reportlab.PmlKeepInFrame instance at 0xa799d4c>,) W [] aH -1.000000000139778e-06 aW 148.18110236220468 canv <reportlab.pdfgen.canvas.Canvas instance at 0xa51442c> s <CellStyle1 '(8, 0)'> sb0 None self PmlTable( rowHeights=[17.249999000000003, 17.249999000000003, ... t 0 v <sx.pisa3.pisa_reportlab.PmlKeepInFrame instance at 0xa799d4c> w 0 * File "/usr/lib/python2.6/dist-packages/reportlab/platypus/flowables.py", line 117, in wrapOn Code fragment: Line 112 113 def wrapOn(self, canv, aW, aH): 114 '''intended for use by packers allows setting the canvas on 115 during the actual wrap''' 116 self.canv = canv 117 w, h = self.wrap(aW,aH) 118 del self.canv 119 return w, h 120 121 def wrap(self, availWidth, availHeight): 122 """This will be called by the enclosing frame before objects Local variables: Name Value aH -1.000000000139778e-06 aW 148.18110236220468 canv <reportlab.pdfgen.canvas.Canvas instance at 0xa51442c> self <sx.pisa3.pisa_reportlab.PmlKeepInFrame instance at 0xa799d4c> * File "/usr/local/lib/python2.6/dist-packages/pisa-3.0.33-py2.6.egg/sx/pisa3/pisa_reportlab.py", line 621, in wrap Code fragment: Line 616 617 def wrap(self, availWidth, availHeight): 618 availWidth = max(availWidth, 1.0) 619 self.maxWidth = availWidth 620 self.maxHeight = self.setMaxHeight(availHeight) 621 return KeepInFrame.wrap(self, availWidth, availHeight) 622 623 class PmlTable(Table, PmlMaxHeightMixIn): 624 625 def _normWidth(self, w, maxw): 626 " Helper for calculating percentages " Local variables: Name Value availHeight -1.000000000139778e-06 availWidth 148.18110236220468 self <sx.pisa3.pisa_reportlab.PmlKeepInFrame instance at 0xa799d4c> * File "/usr/lib/python2.6/dist-packages/reportlab/platypus/flowables.py", line 944, in wrap Code fragment: Line 939 return W,H 940 s0 = s1 941 H0 = H 942 W0 = W 943 s1 = H/maxHeight 944 W, H = func(s1) 945 self.width = W-_FUZZ 946 self.height = H-_FUZZ 947 self._scale = s1 948 if H<min(0.95*maxHeight,maxHeight-10) or H>=maxHeight+_FUZZ: 949 #the standard case W should be OK, H is short we want Local variables: Name Value H 0 H0 0 LayoutError <class 'reportlab.platypus.doctemplate.LayoutError'> W 0 W0 0 availHeight -1.000000000139778e-06 availWidth 148.18110236220468 func <function func at 0xa5c40d4> maxHeight -1.000000000139778e-06 maxWidth 148.18110236220468 mode 'shrink' s0 1 s1 -0.0 self <sx.pisa3.pisa_reportlab.PmlKeepInFrame instance at 0xa799d4c> * File "/usr/lib/python2.6/dist-packages/reportlab/platypus/flowables.py", line 925, in func
Attachments (0)
Change History (4)
comment:1 follow-up: 2 Changed 14 years ago by
Status: | new → assigned |
---|
comment:2 Changed 13 years ago by
Summary: | ZeroDivisionError: float division → ZeroDivisionError: float division (can't install with easy_install) |
---|
Replying to airadier:
Note from the reporter:
I decided to take all dependencies direct from the synaptic package manager (i use ubuntu), not from easy_install or any other source like before. It worked now!! Dependencies from the synaptic package manager that i took: python-pisa, python-pypdf, python-imaging-dbg, python-reportlab, python-pygments, python-html5lib
But normally if i install all the dependencies using easy_install, i don't have to install again through synaptic package manager, right? hmmm... Well.. the important thing is knowing that it's worked...
I had the same issue. Couldn't get it to install with easy_install
. Here is the last bit of the output:
error: ‘PyObject’ undeclared (first use in this function) /tmp/easy_install-a5mfkJ/reportlab-2.5/src/rl_addons/rl_accel/_rl_accel.c:1316: error: expected expression before ‘)’ token /tmp/easy_install-a5mfkJ/reportlab-2.5/src/rl_addons/rl_accel/_rl_accel.c:1320: warning: implicit declaration of function ‘PyErr_Occurred’ /tmp/easy_install-a5mfkJ/reportlab-2.5/src/rl_addons/rl_accel/_rl_accel.c:1320: warning: implicit declaration of function ‘Py_FatalError’ error: Setup script exited with error: command 'gcc' failed with exit status 1
comment:3 Changed 12 years ago by
I've got the same problem. In my case it was an empty row in a table.
This was not working and resulted in ZeroDivisionError:
||text1||text2|| || || || ||text3||text4||
This was working for me:
||text1||text2|| ||text3||text4||
comment:4 Changed 12 years ago by
Owner: | changed from Álvaro Iradier to Ryan J Ollos |
---|---|
Priority: | normal → high |
Status: | assigned → new |
Note from the reporter: