Mercurial > treepkg
changeset 14:dfd89f81e66c
Add simple status report tool. Still using the old status files
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Fri, 09 Mar 2007 19:02:47 +0100 |
parents | 3e6aa2a7f905 |
children | 667ae96b50f7 |
files | reportstatus.py treepkg/packager.py treepkg/util.py |
diffstat | 3 files changed, 54 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/reportstatus.py Fri Mar 09 19:02:47 2007 +0100 @@ -0,0 +1,35 @@ +#! /usr/bin/python2.4 +# Copyright (C) 2007 by Intevation GmbH +# Authors: +# Bernhard Herzog <bh@intevation.de> +# +# This program is free software under the GPL (>=v2) +# Read the file COPYING coming with the software for details. + +"""Reports the current status of the tree packager""" + +import os +from optparse import OptionParser + +from treepkg.packager import create_package_line, PackagerGroup +from treepkg.readconfig import read_config + +def parse_commandline(): + parser = OptionParser() + parser.set_defaults(config_file=os.path.join(os.path.dirname(__file__), + "treepkg.cfg")) + parser.add_option("--config-file") + return parser.parse_args() + +def main(): + options, args = parse_commandline() + + treepkg_opts, packager_opts = read_config(options.config_file) + group = PackagerGroup([create_package_line(**opts) + for opts in packager_opts], + **treepkg_opts) + for line in group.get_package_lines(): + for revision in line.get_revisions(): + print line.name, revision.revision, revision.status.get() + +main()
--- a/treepkg/packager.py Fri Mar 09 18:24:29 2007 +0100 +++ b/treepkg/packager.py Fri Mar 09 19:02:47 2007 +0100 @@ -345,6 +345,11 @@ else: logging.info("New revision already packaged.") + def get_revisions(self): + """Returns RevisionPackager objects for each packaged revision""" + return [self.revision_packager_cls(self, revision) + for revision in self.get_revision_numbers()] + def create_package_line(packager_class, **kw): module = util.import_dotted_name(packager_class) @@ -388,3 +393,6 @@ logging.exception("An error occurred while" " checking packager line %r", line.name) logging.info("Checked all package lines") + + def get_package_lines(self): + return self.package_lines
--- a/treepkg/util.py Fri Mar 09 18:24:29 2007 +0100 +++ b/treepkg/util.py Fri Mar 09 19:02:47 2007 +0100 @@ -109,6 +109,17 @@ assert os.path.isabs(filename) self.filename = filename + def read(self): + f = open(self.filename) + try: + self.status = f.read() + finally: + f.close() + def set(self, status, extra=""): ensure_directory(os.path.dirname(self.filename)) writefile(self.filename, status + "\n" + extra) + + def get(self): + self.read() + return self.status.strip()