[SCM] build.samba.org - branch master updated

Jelmer Vernooij jelmer at samba.org
Fri Nov 19 11:15:24 MST 2010


The branch, master has been updated
       via  4303518 host -> __getitem__
      from  ff66f06 Cope with unknown hosts in dead host list.

http://gitweb.samba.org/?p=build-farm.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 430351844a1450f3466e078658f2f957e95cee08
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri Nov 19 19:15:01 2010 +0100

    host -> __getitem__

-----------------------------------------------------------------------

Summary of changes:
 buildfarm/hostdb.py            |    7 ++-----
 buildfarm/sqldb.py             |    5 ++---
 buildfarm/tests/test_hostdb.py |    2 +-
 buildfarm/web/__init__.py      |   10 +++++-----
 4 files changed, 10 insertions(+), 14 deletions(-)


Changeset truncated at 500 lines:

diff --git a/buildfarm/hostdb.py b/buildfarm/hostdb.py
index c037f2b..b195669 100644
--- a/buildfarm/hostdb.py
+++ b/buildfarm/hostdb.py
@@ -102,13 +102,10 @@ class HostDatabase(object):
         for row in cursor:
             yield Host(row[0], owner=row[1], owner_email=row[2], last_update=row[3])
 
-    def host(self, name):
+    def __getitem__(self, name):
         """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"
@@ -155,7 +152,7 @@ class PlainTextHostDatabase(HostDatabase):
         for name, platform in self._hosts.iteritems():
             yield Host(name, platform=platform)
 
-    def host(self, name):
+    def __getitem__(self, name):
         try:
             return Host(name=name, platform=self._hosts[name])
         except KeyError:
diff --git a/buildfarm/sqldb.py b/buildfarm/sqldb.py
index 540e8a5..58a1ac8 100644
--- a/buildfarm/sqldb.py
+++ b/buildfarm/sqldb.py
@@ -123,14 +123,13 @@ class StormHostDatabase(HostDatabase):
 
     def deletehost(self, name):
         """Remove a host."""
-        host = self.host(name)
-        self.store.remove(host)
+        self.store.remove(self[name])
 
     def hosts(self):
         """Retrieve an iterable over all hosts."""
         return self.store.find(StormHost).order_by(StormHost.name)
 
-    def host(self, name):
+    def __getitem__(self, name):
         ret = self.store.find(StormHost, StormHost.name==name).one()
         if ret is None:
             raise NoSuchHost(name)
diff --git a/buildfarm/tests/test_hostdb.py b/buildfarm/tests/test_hostdb.py
index f946080..f6074cc 100644
--- a/buildfarm/tests/test_hostdb.py
+++ b/buildfarm/tests/test_hostdb.py
@@ -43,7 +43,7 @@ class HostDatabaseTests(object):
 
     def test_host(self):
         newhost = self.db.createhost("charis", u"linux", u"Jelmer", u"jelmer at samba.org", u"bla", u"Pemrission?")
-        samehost = self.db.host("charis")
+        samehost = self.db["charis"]
         self.assertEquals(samehost, newhost)
 
     def test_create_already_exists(self):
diff --git a/buildfarm/web/__init__.py b/buildfarm/web/__init__.py
index 99f5654..0f72c51 100755
--- a/buildfarm/web/__init__.py
+++ b/buildfarm/web/__init__.py
@@ -516,7 +516,7 @@ class ViewBuildPage(BuildFarmPage):
         yield "<table class='real'>\n"
         yield "<tr><td>Host:</td><td><a href='%s?function=View+Host;host=%s;tree=%s;"\
               "compiler=%s#'>%s</a> - %s</td></tr>\n" %\
-                (myself, host, tree, compiler, host, self.buildfarm.hostdb.host(host).platform.encode("utf-8"))
+                (myself, host, tree, compiler, host, self.buildfarm.hostdb[host].platform.encode("utf-8"))
         yield "<tr><td>Uname:</td><td>%s</td></tr>\n" % uname
         yield "<tr><td>Tree:</td><td>%s</td></tr>\n" % self.tree_link(myself, tree)
         yield "<tr><td>Build Revision:</td><td>%s</td></tr>\n" % revision_link(myself, revision, tree)
@@ -596,7 +596,7 @@ class ViewRecentBuildsPage(BuildFarmPage):
 
         for build in self.buildfarm.get_tree_builds(tree):
             try:
-                host = self.buildfarm.hostdb.host(build.host)
+                host = self.buildfarm.hostdb[build.host]
             except hostdb.NoSuchHost:
                 # Skip, at least for now.
                 continue
@@ -681,7 +681,7 @@ class ViewHostPage(BuildFarmPage):
         yield '<h2>Host summary:</h2>'
         for hostname in requested_hosts:
             try:
-                host = self.buildfarm.hostdb.host(hostname)
+                host = self.buildfarm.hostdb[hostname]
             except hostdb.NoSuchHost:
                 deadhosts.append(hostname)
                 continue
@@ -705,7 +705,7 @@ class ViewHostPage(BuildFarmPage):
         for host in requested_hosts:
             # make sure we have some data from it
             try:
-                self.buildfarm.hostdb.host(host)
+                self.buildfarm.hostdb[host]
             except hostdb.NoSuchHost:
                 continue
 
@@ -737,7 +737,7 @@ class ViewHostPage(BuildFarmPage):
             last_build = self.buildfarm.host_last_build(host)
             age = time.time() - last_build
             try:
-                platform = self.buildfarm.hostdb.host(host).platform.encode("utf-8")
+                platform = self.buildfarm.hostdb[host].platform.encode("utf-8")
             except hostdb.NoSuchHost:
                 platform = "UNKNOWN"
             yield "<tr><td>%s</td><td>%s</td><td>%s</td></tr>" %\


-- 
build.samba.org


More information about the samba-cvs mailing list