Add convenience function for opening host database.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 8 Nov 2010 07:52:54 +0000 (08:52 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 8 Nov 2010 07:52:54 +0000 (08:52 +0100)
admin.py
buildfarm/__init__.py
mail-dead-hosts.py
web/build.py

index 731876c40acf812cc1e5372e5b2e3af06de4b256..d94b572135e842ba7e087e51909db961a7c95f03 100755 (executable)
--- a/admin.py
+++ b/admin.py
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-from buildfarm import hostdb
+from buildfarm import (
+    hostdb,
+    open_hostdb,
+    )
 import commands
 import os
 import smtplib
@@ -25,7 +28,7 @@ import sys
 import time
 from email.MIMEText import MIMEText
 
-db = hostdb.HostDatabase(os.path.join(os.path.dirname(__file__), "hostdb.sqlite"))
+db = open_hostdb()
 
 dry_run = False
 
index 8b137891791fe96927ad78e64b0aad7bded08bdc..e133cda56206e0fe23fb9f6290887c23ed91f1da 100644 (file)
@@ -1 +1,25 @@
+#!/usr/bin/python
+# Simple database query script for the buildfarm
+#
+# Copyright (C) Jelmer Vernooij <jelmer@samba.org>        2010
+#
+#   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 2 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, write to the Free Software
+#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
+import os
+
+def open_hostdb():
+    from buildfarm import hostdb
+    return hostdb.HostDatabase(
+        os.path.join(os.path.dirname(__file__), "..", "hostdb.sqlite"))
index ca42a3b653576d2e4af3508c7c84e1134d212106..725baa3c68e9b9ec6e3afdc4f13b1a8e5fc69af2 100755 (executable)
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
-from buildfarm import hostdb
+from buildfarm import (
+    hostdb,
+    open_hostdb,
+    )
 import smtplib
 from email.MIMEText import MIMEText
-import os
 import time
 
-db = hostdb.HostDatabase(os.path.join(os.path.dirname(__file__), "hostdb.sqlite"))
+db = open_hostdb()
 dry_run = False
 
 hosts = db.dead_hosts(7 * 86400)
index 93c60863269ad17f84aa8cac95b27376585e9ba7..b63061b648f989021b33a78a17396db87671f38c 100755 (executable)
@@ -33,6 +33,7 @@ from buildfarm import (
     data,
     history,
     hostdb,
+    open_hostdb,
     util,
     )
 
@@ -47,7 +48,7 @@ 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__), "..", "hostdb.sqlite"))
+hostsdb = open_hostdb()
 
 compilers = db.compilers
 hosts = dict([(host.name, host) for host in hostsdb.hosts()])