Cope with nonexistant hosts.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 19 Nov 2010 18:05:18 +0000 (19:05 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 19 Nov 2010 18:05:18 +0000 (19:05 +0100)
buildfarm/hostdb.py
buildfarm/web/__init__.py

index 24186c24529bef2b5b23277a7c7261c902f9a1fe..c037f2b1f180fba18158e163cfdd07c792bd4aa1 100644 (file)
@@ -106,6 +106,9 @@ class HostDatabase(object):
         """Find a host by name."""
         raise NotImplementedError(self.host)
 
+    def __getitem__(self, name):
+        return self.host(name)
+
     def create_rsync_secrets(self):
         """Write out the rsyncd.secrets"""
         yield "# rsyncd.secrets file\n"
index d1f7a74b843b975515cd53971580730d68684df4..9be4821f9e226804bb004b628884e2a6fa0a2363 100755 (executable)
@@ -656,7 +656,7 @@ class ViewHostPage(BuildFarmPage):
     def _render_build_list_header(self, host):
         yield "<div class='host summary'>"
         yield "<a id='host' name='host'/>"
-        yield "<h3>%s - %s</h3>" % (host, self.buildfarm.hostdb.host(host).platform.encode("utf-8"))
+        yield "<h3>%s - %s</h3>" % (host.name, host.platform.encode("utf-8"))
         yield "<table class='real'>"
         yield "<thead><tr><th>Target</th><th>Build<br/>Revision</th><th>Build<br />Age</th><th>Status<br />config/build<br />install/test</th><th>Warnings</th></tr></thead>"
         yield "<tbody>"
@@ -679,8 +679,13 @@ class ViewHostPage(BuildFarmPage):
     def render_html(self, myself, *requested_hosts):
         yield "<div class='build-section' id='build-summary'>"
         yield '<h2>Host summary:</h2>'
-        for host in requested_hosts:
-            builds = list(self.buildfarm.get_host_builds(host))
+        for hostname in requested_hosts:
+            try:
+                host = self.buildfarm.hostdb.host(hostname)
+            except hostdb.NoSuchHost:
+                deadhosts.append(hostname)
+                continue
+            builds = list(self.buildfarm.get_host_builds(hostname))
             if len(builds) > 0:
                 yield "".join(self._render_build_list_header(host))
                 for build in builds:
@@ -688,7 +693,7 @@ class ViewHostPage(BuildFarmPage):
                 yield "</tbody></table>"
                 yield "</div>"
             else:
-                deadhosts.append(host)
+                deadhosts.append(hostname)
 
         yield "</div>"
         yield "".join(self.draw_dead_hosts(*deadhosts))