From f006517e6d6b8dbc791b549d998c5a17b81f062c Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 15 Nov 2008 22:58:47 +0100 Subject: [PATCH] Updated some things in builder. I added a box for distcc hosts and some lines that clean up the databases by themselves. Nice, eh? --- build/builder.py | 26 ++++++ build/constants.py | 8 ++ build/index.py | 194 +++++++++++++++++++++++++++++---------------- 3 files changed, 159 insertions(+), 69 deletions(-) diff --git a/build/builder.py b/build/builder.py index b83591f0..bef9b0a2 100644 --- a/build/builder.py +++ b/build/builder.py @@ -24,6 +24,7 @@ import sys import time import socket import base64 +import shutil from pysqlite2 import dbapi2 as sqlite sys.path.append(".") @@ -223,6 +224,31 @@ class Builder: self.distcc = DistccConfig(self.db, "distcc", self.hostname(), self.jobs()) self.log = FileConfig(self.path, "log") + + # If host was longer than 3 days in state compiling we set it as idle. + if self.state() == "compiling" and \ + (time.time() - self.state.time()) > 3*24*60*60: + self.state.set("idle") + + # If host is idle and distcc is not disabled we set it as distcc host. + if self.state() == "idle" and self.distcc() != "0": + self.state.set("distcc") + + # If host is longer than 24h in error state we set it as distcc host. + if self.state() == "error" and \ + (time.time() - self.state.time()) > 24*60*60: + self.state.set("distcc") + + # If host was longer than two weeks in distcc state we set it as unknown. + if self.state() == "error" and \ + (time.time() - self.state.time()) > 2*7*24*60*60: + self.state.set("unknown") + + # If host was longer than four weels in distcc state we delete it. + if self.state() == "unknown" and \ + (time.time() - self.state.time()) > 4*7*24*60*60: + del self.db + shutil.rmtree(self.path) def set(self, key, value): eval("self.%s.set(\"%s\")" % (key, value,)) diff --git a/build/constants.py b/build/constants.py index 3c55dd15..33008ee1 100644 --- a/build/constants.py +++ b/build/constants.py @@ -22,6 +22,12 @@ import os import time +POINTS_UNKNOWN = 0 +POINTS_IDLE = 1 +POINTS_DISTCC = 2 +POINTS_ERROR = 4 +POINTS_COMPILING = 8 + config = { "title" : "IPFire - Builder", "nightly_url" : ("ftp://ftp.ipfire.org/pub/nightly-builds/", "http://www.rowie.at/upload/ipfire/builds/",), @@ -36,6 +42,7 @@ statedesc = { "compiling" : "The host is really hard working at the moment...", "error" : "Oops! The host had an error...", "idle" : "The host is idle at the moment...", + "distcc" : "This host is waiting for distcc requests...", } ping2class = { @@ -46,6 +53,7 @@ ping2class = { state2style = { None : "", "compiling" : "background: #8C8; border: 1px solid #0e0;", + "distcc" : "background: #58c; border: 1px solid #8ac;", "error" : "background: #c33; border: 1px solid #e00;", "idle" : "background: #ddd; border: 1px solid #eee;", } diff --git a/build/index.py b/build/index.py index 3a78d12f..4315b9bc 100644 --- a/build/index.py +++ b/build/index.py @@ -143,14 +143,6 @@ class Site: