Opened on 11/12/2014 at 07:14:30 PM

Closed on 11/12/2014 at 09:13:21 PM

#1560 closed defect (fixed)

ZeroDivisionError in sitescripts.stats.bin.pagegenerator

Reported by: trev Assignee: trev
Priority: P1 Milestone:
Module: Infrastructure Keywords:
Cc: Blocked By:
Blocking: Platform: Unknown
Ready: yes Confidential: no
Tester: Verified working: no
Review URL(s):



Our stats server was producing errors when generating pages lately:

  File "/opt/sitescripts/sitescripts/stats/template/fileStats.html", line 141, in top-level template code
    {{row(field.title, data[].True, params, chart=False,
  File "/opt/sitescripts/sitescripts/stats/template/fileStats.html", line 93, in template
    <td align="right">{{(value.bandwidth / params.totalbandwidth * 100)|round(precision=1)}}%</td>
ZeroDivisionError: division by zero

Apparently, params.totalbandwidth is zero. We didn't consider that scenario when the script was created - there must be at least one hit, otherwise no statistics would exist for that file. Here that hit apparently produced zero bandwidth which is highly unusual but not impossible.

What to change

We should guard against division by zero here, similarly to how it is done elsewhere.

Attachments (0)

Change History (2)

comment:1 Changed on 11/12/2014 at 07:43:30 PM by trev

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:2 Changed on 11/12/2014 at 09:13:21 PM by trev

  • Resolution set to fixed
  • Status changed from reviewing to closed

Add Comment

Modify Ticket

Change Properties
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from trev.
Note: See TracTickets for help on using tickets.