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

Jelmer Vernooij jelmer at samba.org
Sat Nov 6 17:24:29 MDT 2010


The branch, master has been updated
       via  5b7936c Add python version of mail-dead-hosts script.
       via  529cac0 directly access the hosts list from the sqlite database in the web build.
      from  6ee58c0 Remove old admin script.

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


- Log -----------------------------------------------------------------
commit 5b7936c09dabcc645f63aa6c3ee04e44c141903b
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Nov 7 00:25:04 2010 +0100

    Add python version of mail-dead-hosts script.

commit 529cac0e51d39601a9c91a21e01d09660fd83196
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Sun Nov 7 00:14:43 2010 +0100

    directly access the hosts list from the sqlite database in the web build.

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

Summary of changes:
 buildfarm/data.py            |    1 -
 buildfarm/hostdb.py          |    2 +-
 buildfarm/tests/__init__.py  |    8 ----
 buildfarm/tests/test_data.py |    1 -
 mail-dead-hosts.py           |   73 ++++++++++++++++++++++++++++++++++++++++++
 web/build.py                 |   10 ++++-
 6 files changed, 82 insertions(+), 13 deletions(-)
 create mode 100755 mail-dead-hosts.py


Changeset truncated at 500 lines:

diff --git a/buildfarm/data.py b/buildfarm/data.py
index 2bbbd74..437cd76 100644
--- a/buildfarm/data.py
+++ b/buildfarm/data.py
@@ -335,7 +335,6 @@ class BuildResultStore(object):
         check_dir_exists("lcov", self.lcovdir)
 
         self.compilers = util.load_list(os.path.join(self.webdir, "compilers.list"))
-        self.hosts = util.load_hash(os.path.join(self.webdir, "hosts.list"))
 
         self.trees = read_trees_from_conf(os.path.join(self.webdir, "trees.conf"))
 
diff --git a/buildfarm/hostdb.py b/buildfarm/hostdb.py
index 51dafba..3c42757 100644
--- a/buildfarm/hostdb.py
+++ b/buildfarm/hostdb.py
@@ -108,7 +108,7 @@ class HostDatabase(object):
             yield Host(row[0], owner=row[1], owner_email=row[2], last_update=row[3])
 
     def sent_dead_mail(self, host):
-        self.db.execute("UPDATE host SET last_dead_mail = ? WHERE name = ?", time.time(), host)
+        self.db.execute("UPDATE host SET last_dead_mail = ? WHERE name = ?", (int(time.time()), host))
         self.db.commit()
 
     def host(self, name):
diff --git a/buildfarm/tests/__init__.py b/buildfarm/tests/__init__.py
index 130c3b9..260e006 100644
--- a/buildfarm/tests/__init__.py
+++ b/buildfarm/tests/__init__.py
@@ -46,14 +46,6 @@ class BuildFarmTestCase(TestCase):
             f.close()
         return path
 
-    def write_hosts(self, hosts):
-        f = open(os.path.join(self.path, "web", "hosts.list"), "w")
-        try:
-            for host in hosts:
-                f.write("%s\n" % host)
-        finally:
-            f.close()
-
     def write_compilers(self, compilers):
         f = open(os.path.join(self.path, "web", "compilers.list"), "w")
         try:
diff --git a/buildfarm/tests/test_data.py b/buildfarm/tests/test_data.py
index b566c73..71ad682 100755
--- a/buildfarm/tests/test_data.py
+++ b/buildfarm/tests/test_data.py
@@ -85,7 +85,6 @@ class BuildResultStoreTests(BuildFarmTestCase):
         super(BuildResultStoreTests, self).setUp()
 
         self.write_compilers(["cc"])
-        self.write_hosts(["gwenhwyvar", "charis"])
         self.write_trees({"tdb": {"scm": "git", "repo": "tdb", "branch": "master"}})
 
         self.x = data.BuildResultStore(self.path)
diff --git a/mail-dead-hosts.py b/mail-dead-hosts.py
new file mode 100755
index 0000000..ca42a3b
--- /dev/null
+++ b/mail-dead-hosts.py
@@ -0,0 +1,73 @@
+#!/usr/bin/python
+# Samba.org buildfarm
+# Copyright (C) 2008 Andrew Bartlett <abartlet at samba.org>
+# Copyright (C) 2008-2010 Jelmer Vernooij <jelmer at samba.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+from buildfarm import hostdb
+import smtplib
+from email.MIMEText import MIMEText
+import os
+import time
+
+db = hostdb.HostDatabase(os.path.join(os.path.dirname(__file__), "hostdb.sqlite"))
+dry_run = False
+
+hosts = db.dead_hosts(7 * 86400)
+for host in hosts:
+    db.sent_dead_mail(host.name)
+
+    if host.last_update:
+        last_update = time.strftime ("%a %b %e %H:%M:%S %Y", time.gmtime(host.last_update))
+    else:
+        last_update = "a long time"
+
+    body = """
+Your host %s has been part of the Samba Build farm, hosted
+at http://build.samba.org.
+
+Sadly however we have not heard from it since %s.
+
+Could you see if something has changed recently, and examine the logs
+(typically in ~build/build_farm/build.log and ~build/cron.err) to see
+why we have not heard from your host?
+
+If you no longer wish your host to participate in the Samba Build
+Farm, then please let us know so we can remove its records.
+
+You can see the summary for your host at:
+http://build.samba.org/?function=View+Host;host=%s
+
+Thanks,
+
+The Build Farm administration team.
+
+""" % (host.name, last_update, host.name)
+
+    msg = MIMEText(body)
+
+    # send an e-mail to the owner
+    msg["Subject"] ="Your build farm host %s appears dead" % host.name
+    msg["From"] = "\"Samba Build Farm\" <build at samba.org>"
+    msg["To"] = "\"%s\" <%s>" % host.owner
+
+    if dry_run:
+        print msg.as_string()
+    else:
+        s = smtplib.Connection()
+        s.connect()
+        s.send(msg["From"], [msg["To"]], msg.as_string())
+        s.quit()
diff --git a/web/build.py b/web/build.py
index 0fc0bfd..fc27aea 100755
--- a/web/build.py
+++ b/web/build.py
@@ -29,7 +29,12 @@ import os
 import sys
 sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
 
-from buildfarm import data, util, history
+from buildfarm import (
+    data,
+    history,
+    hostdb,
+    util,
+    )
 
 import cgi
 import re
@@ -42,9 +47,10 @@ basedir = os.path.abspath(os.path.join(webdir, ".."))
 
 db = data.BuildResultStore(basedir)
 history = history.History(db)
+hostsdb = hostdb.HostDatabase(os.path.join(os.path.dirname(__file__), "..", "hosts.sqlite"))
 
 compilers = db.compilers
-hosts = db.hosts
+hosts = hostsdb.hosts()
 trees = db.trees
 OLDAGE = db.OLDAGE
 


-- 
build.samba.org


More information about the samba-cvs mailing list