mutable status: make the 'total' timing value optional: unit tests fail otherwise
authorBrian Warner <warner@allmydata.com>
Tue, 22 Apr 2008 00:29:12 +0000 (17:29 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 22 Apr 2008 00:29:12 +0000 (17:29 -0700)
src/allmydata/web/status.py

index 83e3773a63c4346e0a8562ca3a25b3763124f6c9..1ea0305a4d9d0c95be4b921178c33b77c9db6a98 100644 (file)
@@ -710,7 +710,7 @@ class MapupdateStatusPage(rend.Page, RateAndTimeMixin):
 
     def _timing_chart(self):
         started = self.update_status.get_started()
-        total = self.update_status.timings["total"]
+        total = self.update_status.timings.get("total")
         per_server = self.update_status.timings.get("per_server")
         base = "http://chart.apis.google.com/chart?"
         pieces = ["cht=bhs", "chs=400x300"]
@@ -759,10 +759,11 @@ class MapupdateStatusPage(rend.Page, RateAndTimeMixin):
         # mathutil.next_power_of_k doesn't handle numbers smaller than one,
         # unfortunately.
         #pieces.append("chg="
-        # this chm=r thing is being interpreted as 1.0=fullscale
-        finished_f = 1.0 * total / top_rel
-        pieces.append("chm=r,FF0000,0,%0.3f,%0.3f" % (finished_f,
-                                                      finished_f+0.01))
+
+        if total is not None:
+            finished_f = 1.0 * total / top_rel
+            pieces.append("chm=r,FF0000,0,%0.3f,%0.3f" % (finished_f,
+                                                          finished_f+0.01))
         url = base + "&".join(pieces)
         return T.img(src=url, align="right", float="right")