[Treepkg-commits] r328 - in trunk: . bin treepkg
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Jun 21 10:23:32 CEST 2010
Author: aheinecke
Date: 2010-06-21 10:23:30 +0200 (Mon, 21 Jun 2010)
New Revision: 328
Modified:
trunk/bin/createstaticweb.py
trunk/bin/publishstaticweb.py
trunk/demostaticweb.cfg
trunk/treepkg/packager.py
trunk/treepkg/report.py
trunk/treepkg/web.py
Log:
Added the option to expose additional log files from the log directory.
To enable this one can either set a build_logs value in the staticweb.cfg
or call createstaticweb with the parameter --show-logs. Default behavior is
to only publish the build log, although the title is now capitalized.
Modified: trunk/bin/createstaticweb.py
===================================================================
--- trunk/bin/createstaticweb.py 2010-06-15 10:56:44 UTC (rev 327)
+++ trunk/bin/createstaticweb.py 2010-06-21 08:23:30 UTC (rev 328)
@@ -18,21 +18,31 @@
def parse_commandline():
parser = create_parser()
parser.set_defaults(status_template="status-by-startdate.html")
+ parser.set_defaults(show_logs="build_log.txt.gz")
parser.add_option("--status-template",
help=("The template file to use for the status page."
" Relative filenames are interpreted"
" relative to the web subdirectory."
" Default is status-by-startdate.html."))
+ parser.add_option("--show-logs",
+ help=("A comma seperated list of filenames of the"
+ " logs that should be included in the status page."
+ " Valid names are filenames of the files"
+ " in the log dir of a package. e.g."
+ " --show-logs=tarball_log.txt,dpkg_source.txt"
+ " Default is build_log.txt.gz"))
return parser.parse_args()
-def create_static_site(treepkg_config, status_template, destdir):
- status = Status(treepkg_config=treepkg_config, template=status_template)
+def create_static_site(treepkg_config, status_template, show_logs, destdir):
+ status = Status(treepkg_config=treepkg_config, template=status_template,
+ logs=show_logs.split(","))
status.create_static_site(destdir)
def main():
options, args = parse_commandline()
create_static_site(options.config_file,
options.status_template,
+ options.show_logs,
args[0])
main()
Modified: trunk/bin/publishstaticweb.py
===================================================================
--- trunk/bin/publishstaticweb.py 2010-06-15 10:56:44 UTC (rev 327)
+++ trunk/bin/publishstaticweb.py 2010-06-21 08:23:30 UTC (rev 328)
@@ -29,14 +29,21 @@
return os.path.expandvars(os.path.expanduser(filename))
staticweb_desc = ["build_user", "build_host", "build_create", "build_template",
+ "build_logs",
("build_dir", remove_trailing_slashes),
"publish_user", "publish_host",
("publish_dir", remove_trailing_slashes),
("cachedir",
lambda s: expand_filename(remove_trailing_slashes(s)))]
+#Default values for the configuration options can be set here
+staticweb_defaults = [("build_logs", "build_log.txt.gz")]
+
def read_config(filename):
parser = SafeConfigParser()
+ parser.add_section("staticweb")
+ for value in staticweb_defaults:
+ parser.set("staticweb", value[0], value[1])
parser.read([filename])
return read_config_section(parser, "staticweb", staticweb_desc)
@@ -58,6 +65,7 @@
# create web-page on build host
call(cmdexpand("ssh $build_user$@$build_host $build_create"
+ " --show-logs=$build_logs"
" --status-template=$build_template $build_dir",
**config))
Modified: trunk/demostaticweb.cfg
===================================================================
--- trunk/demostaticweb.cfg 2010-06-15 10:56:44 UTC (rev 327)
+++ trunk/demostaticweb.cfg 2010-06-21 08:23:30 UTC (rev 328)
@@ -23,6 +23,12 @@
# to the ~/treepkg/web/ directory.
build_template: status-by-startdate.html
+# Additional log files can be configured here, those can have non standard
+# names as long as they are contained in the log directory of a package.
+# Filenames have to be seperated by a comma.
+# Default is: build_log.txt.gz
+# build_logs: build_log.txt.gz,tarball_log.txt,pkits_log.txt
+
# the directory on build_host where the static web-site should be put.
# This value is used as the parameter to the build_create command on
# build_host.
Modified: trunk/treepkg/packager.py
===================================================================
--- trunk/treepkg/packager.py 2010-06-15 10:56:44 UTC (rev 327)
+++ trunk/treepkg/packager.py 2010-06-21 08:23:30 UTC (rev 328)
@@ -308,20 +308,39 @@
def has_build_log(self):
return os.path.exists(self.get_log_file())
+ def get_log_title(self, f):
+ if not os.path.isfile(f):
+ return None
+ title = os.path.basename(f)
+ title = title.replace("_"," ")
+ title = title[:title.find(".")]
+ title = title.title()
+ return title
+
def get_log_file(self):
if os.path.exists(self.build_log + ".gz"):
return self.build_log + ".gz"
return self.build_log
- def list_log_files(self):
+ def get_log_files(self, logs):
+ files = []
+ for f in os.listdir(self.log_dir):
+ if f in logs:
+ f = os.path.join(self.log_dir,f)
+ if os.path.isfile(f):
+ files.append((self.get_log_title(f),f))
+ return files
+
+ def list_log_files(self, logs):
"""Returns a list describing the logfiles available for the revision.
Each list item is a tuple of the form (TITLE, FILENAME) where
- TITLE is a string with a title usable in e. g. a web-page, and
+ TITLE is a string with the filename without directory or ending in
+ which _ is replaced with a whitespace and words are capitalized.
FILENAME is the absolute filename of the log file.
"""
- files = []
- if self.has_build_log():
- files.append(("build log", self.get_log_file()))
+ files = self.get_log_files(logs)
+ if not files:
+ return []
return files
def list_source_files(self):
Modified: trunk/treepkg/report.py
===================================================================
--- trunk/treepkg/report.py 2010-06-15 10:56:44 UTC (rev 327)
+++ trunk/treepkg/report.py 2010-06-21 08:23:30 UTC (rev 328)
@@ -68,8 +68,9 @@
class Revisions(object):
- def __init__(self, tracks):
+ def __init__(self, tracks, logs):
self.tracks = sorted(tracks, key=attrgetter("name"))
+ self.logs = logs
def sorted_by_revision(self):
revisions = {}
@@ -80,7 +81,8 @@
revision.rules_revision),
[None] * num_columns)
log_files = [(title, os.path.basename(filename))
- for title, filename in revision.list_log_files()]
+ for title, filename in
+ revision.list_log_files(self.logs)]
row[column] = struct(revno=revision.revision,
rulesrev=revision.rules_revision,
revision=revision,
@@ -107,7 +109,8 @@
log_files =
[(title, os.path.basename(filename))
for title, filename
- in revision.list_log_files()],
+ in revision.list_log_files(
+ self.logs)],
column=column,
name=track.name,
new_date = None,
@@ -122,6 +125,6 @@
rev.new_date = str(last_date)
return revisions
-def prepare_report(group):
- return struct(revisions=Revisions(group.get_package_tracks()),
+def prepare_report(group, logs):
+ return struct(revisions=Revisions(group.get_package_tracks(), logs),
date=format_time(datetime.datetime.utcnow()))
Modified: trunk/treepkg/web.py
===================================================================
--- trunk/treepkg/web.py 2010-06-15 10:56:44 UTC (rev 327)
+++ trunk/treepkg/web.py 2010-06-21 08:23:30 UTC (rev 328)
@@ -22,9 +22,10 @@
"""Implements the tree packager status pages"""
- def __init__(self, treepkg_config, template):
+ def __init__(self, treepkg_config, template, logs):
self.treepkg_config = treepkg_config
self.template = template
+ self.logs = logs
self.loader = TemplateLoader([os.path.join(os.path.dirname(__file__),
os.path.pardir,
"web")])
@@ -33,7 +34,7 @@
def index(self):
group = report.get_packager_group(self.treepkg_config)
tmpl = self.loader.load(self.template)
- stream = tmpl.generate(report=report.prepare_report(group))
+ stream = tmpl.generate(report=report.prepare_report(group, self.logs))
return stream.render('html')
def determine_log_filename(self, package_track_name, revdir, log_basename):
@@ -46,7 +47,8 @@
for revision in track.get_revisions():
if (revision.revision == revno
and revision.rules_revision == rulesrev):
- for title, filename in revision.list_log_files():
+ for title, filename in revision.list_log_files(
+ self.logs):
if os.path.basename(filename) == log_basename:
return filename
@@ -88,7 +90,7 @@
if not os.path.isdir(trackdir):
os.mkdir(trackdir)
os.mkdir(revdir)
- for title, filename in revision.list_log_files():
+ for title, filename in revision.list_log_files(self.logs):
os.symlink(filename,
os.path.join(revdir,
os.path.basename(filename)))
More information about the Treepkg-commits
mailing list