changeset 64:2ff966839859

web: add method to create a static status web-site
author Bernhard Herzog <bh@intevation.de>
date Wed, 11 Apr 2007 16:52:58 +0200
parents b076e3895482
children bebe06ff4bd6
files treepkg/web.py
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/treepkg/web.py	Tue Apr 10 20:15:15 2007 +0200
+++ b/treepkg/web.py	Wed Apr 11 16:52:58 2007 +0200
@@ -6,6 +6,7 @@
 # Read the file COPYING coming with the software for details.
 
 import os
+import shutil
 
 from genshi.template import TemplateLoader
 
@@ -52,6 +53,31 @@
         else:
             raise cherrypy.HTTPError(status="404")
 
+    def create_static_site(self, destdir):
+        """Creates a static web-page under destdir"""
+        # make sure we have an empty destdir
+        shutil.rmtree(destdir, True)
+        os.mkdir(destdir)
+
+        # create the index file
+        f = open(os.path.join(destdir, "index.html"), "wt")
+        f.write(self.index())
+        f.close()
+
+        # symlink the build-logs
+        group = report.get_packager_group(self.treepkg_config)
+        for track in group.get_package_tracks():
+            trackdir = os.path.join(destdir, track.name)
+            for revision in track.get_revisions():
+                revdir = os.path.join(trackdir, str(revision.revision))
+                if revision.has_build_log():
+                    if not os.path.isdir(trackdir):
+                        os.mkdir(trackdir)
+                    os.mkdir(revdir)
+                    os.symlink(revision.build_log,
+                               os.path.join(revdir, "build.log"))
+
+
 
 
 class TreePKG(object):
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)