From: Michael Tremer Date: Sat, 25 Jul 2009 16:37:44 +0000 (+0200) Subject: Add a page to view nightly builds. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dd8152dd99082917f5770e5d6b2629caeb3b1de7;p=ipfire.org.git Add a page to view nightly builds. --- diff --git a/www/include/style.css b/www/include/style.css index 8ec192c5..c993139d 100644 --- a/www/include/style.css +++ b/www/include/style.css @@ -439,6 +439,24 @@ table { width: 50px; } +#builds { + width: 100%; + font-size: 0.9em; +} +#builds img { + border: 0; +} +#builds td { + text-align: left; +} +#builds tr.headline td { + text-align: center; + font-weight: bold; +} +#builds td.packages { + text-align: right; +} + /* Footer */ #footer diff --git a/www/info.json b/www/info.json index 802dcecc..2d9cbdb7 100644 --- a/www/info.json +++ b/www/info.json @@ -4,5 +4,8 @@ "slogan" : "Security now!", "releases" : { "stable" : "IPFire 2.5 - Core 28", "testing" : "IPFire 3.0 alpha 1" }, - "hosting" : { "cluster" : "minerva.ipfire.org" } + "hosting" : { "cluster" : "minerva.ipfire.org" }, + "nightly_builds" : [{ "url" : "http://ftp.ipfire.org/pub/nightly-builds/", + "path" : "/srv/anonftp/pub/nightly-builds" }, + { "url" : "http://www.rowie.at/upload/ipfire/builds/" }] } diff --git a/www/pages/builds.py b/www/pages/builds.py new file mode 100644 index 00000000..ce2cf048 --- /dev/null +++ b/www/pages/builds.py @@ -0,0 +1,174 @@ +#!/usr/bin/python + +import os +import time + +import web +import web.elements + +from web.info import Info +info = Info() + +def size(file): + size = os.path.getsize(file) + suffixes = [("B",2**10), ("K",2**20), ("M",2**30), ("G",2**40), ("T",2**50)] + for suf, lim in suffixes: + if size > lim: + continue + else: + return "%s%s" % (round(size/float(lim/2**10),2), suf) + + +class Build(object): + def __init__(self, path, basedir, url): + self.path = path + self.basedir = basedir + self.url = os.path.join(url, path[len(basedir)+1:]) + + # Read .buildinfo + f = open("%s/.buildinfo" % path) + self.info = f.readlines() + f.close() + + def __repr__(self): + return "" % self.path + + def __cmp__(self, other): + return cmp(float(other.get("date")), float(self.get("date"))) + + def get(self, key): + key = key.upper() + "=" + for line in self.info: + if line.startswith(key): + return line.split("=")[1].rstrip("\n") + return None + + @property + def hostname(self): + return self.get("hostname") + + @property + def release(self): + return self.get("release") + + @property + def date(self): + return time.strftime("%Y-%m-%d %H:%M", time.localtime(float(self.get("date")))) + + @property + def arch(self): + return self.get("arch") + + @property + def duration(self): + if not self.get("duration") or self.get("duration") == "": + return "--:--" + return time.strftime("%H:%M", time.gmtime(float(self.get("duration")))) + + @property + def iso(self): + return self.get("iso") + + @property + def packages(self): + return os.listdir("%s/packages_%s" % (self.path, self.arch,)) + + @property + def pxe(self): + dir = "/srv/www/ipfire.org/pxe" + for iso in os.listdir(dir): + # Skip non-iso files + if not iso.endswith(".iso"): + continue + if os.readlink(os.path.join(dir, iso)) == os.path.join(self.path, self.iso): + return "[PXE]" + return "" + + +class Content(web.Content): + def __init__(self): + web.Content.__init__(self) + + self.builds = [] + for location in info["nightly_builds"]: + # Only process correctly configured locations + if not location.has_key("path") or not location.has_key("url"): + continue + + # Continue if path does not exist + if not os.path.exists(location["path"]): + continue + + for (dir, subdirs, files) in os.walk(location["path"]): + if not os.path.exists("%s/.buildinfo" % dir): + continue + self.builds.append(Build(dir, location["path"], location["url"])) + self.builds.sort() + + def __call__(self, lang): + today = time.strftime("%A, %Y-%m-%d", time.localtime()) + last_day = "" + + ret = """

Nightly builds

+ + + """ + + # if there are no builds + if not self.builds: + ret += """""" + + else: + for build in self.builds: + # write headers + day = time.strftime("%A, %Y-%m-%d", time.localtime(float(build.get("date")))) + if day != last_day: + if day == today: + ret += """""" + else: + ret += """""" % day + last_day = day + + if day == today: + ret += "" + else: + ret += """""" + + ret += """\ + + + + + """ % { "release" : build.release, + "hostname" : build.hostname, + "arch" : build.arch, + "date" : build.date, + "duration" : build.duration, + "url" : build.url, + "iso" : build.iso, + "size_iso" : size(os.path.join(build.path, build.iso)), + "num_packages" : len(build.packages), + "pxe" : build.pxe } + + ret += """\ + +
There are currently no builds available.
Today
 
 
%s
+ IPFire 
+ %(release)s (%(arch)s) %(pxe)s
+ %(iso)s %(size_iso)s
 
+ %(hostname)s
+ %(date)s [%(duration)sh]
%(num_packages)s [PAKS]
""" + + return ret + + +page = web.Page() +page.content = Content() +page.sidebar = web.elements.DevelopmentSidebar()