Ticket #1166: 1166-zerodiv.diff

File 1166-zerodiv.diff, 1.4 KB (added by warner, at 2010-08-11T07:16:37Z)

avoid divide-by-zero. Windows, how I hate thee.

  • src/allmydata/web/status.py

    diff --git a/src/allmydata/web/status.py b/src/allmydata/web/status.py
    index 8af453c..8f7b930 100644
    a b class DownloadStatusPage(DownloadResultsRendererMixin, rend.Page): 
    433433            (start, length, requesttime, finishtime, bytes, decrypt, paused) = r_ev
    434434            if finishtime is not None:
    435435                rtt = finishtime - requesttime - paused
    436                 speed = self.render_rate(None, 1.0 * bytes / rtt)
     436                if rtt == 0:
     437                    speed = "-"
     438                else:
     439                    speed = self.render_rate(None, 1.0 * bytes / rtt)
    437440                rtt = self.render_time(None, rtt)
    438441                decrypt = self.render_time(None, decrypt)
    439442                paused = self.render_time(None, paused)
    class DownloadStatusPage(DownloadResultsRendererMixin, rend.Page): 
    459462            elif etype == "delivery":
    460463                if reqtime[0] == segnum:
    461464                    segtime = when - reqtime[1]
    462                     speed = self.render_rate(None, 1.0 * seglen / segtime)
     465                    if segtime == 0:
     466                        speed = "-"
     467                    else:
     468                        speed = self.render_rate(None, 1.0 * seglen / segtime)
    463469                    segtime = self.render_time(None, segtime)
    464470                else:
    465471                    segtime, speed = "", ""