Mercurial > treepkg
changeset 41:f7ec40638a06
use the enums for the status field of RevisionStatus
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Thu, 15 Mar 2007 21:12:23 +0100 (2007-03-15) |
parents | c544903eeced |
children | bad59cd04f34 3c5ab7a65384 |
files | treepkg/packager.py treepkg/report.py treepkg/status.py |
diffstat | 3 files changed, 17 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/treepkg/packager.py Thu Mar 15 21:03:44 2007 +0100 +++ b/treepkg/packager.py Thu Mar 15 21:12:23 2007 +0100 @@ -154,9 +154,9 @@ """ util.ensure_directory(self.work_dir) try: - self.status.status = "creating_source_package" + self.status.creating_source_package() self.do_package() - self.status.status = "source_package_created" + self.status.source_package_created() finally: logging.info("Removing workdir %r", self.work_dir) shutil.rmtree(self.work_dir) @@ -182,13 +182,13 @@ self.logfile = logfile def package(self): - self.status.status = "creating_binary_package" + self.status.creating_binary_package() util.ensure_directory(self.binary_dir) logging.info("Building binary package; loging to %r", self.logfile) cmd = ["/usr/sbin/pbuilder", "build", "--logfile", self.logfile, "--buildresult", self.binary_dir, self.dsc_file] run.call(self.pkg_line.root_cmd + cmd, suppress_output=True) - self.status.status = "binary_package_created" + self.status.binary_package_created() class RevisionPackager(object): @@ -236,7 +236,7 @@ bin_packager.package() self.status.stop = datetime.datetime.utcnow() except: - self.status.status = "error" + self.status.error() self.status.stop = datetime.datetime.utcnow() raise
--- a/treepkg/report.py Thu Mar 15 21:03:44 2007 +0100 +++ b/treepkg/report.py Thu Mar 15 21:12:23 2007 +0100 @@ -32,24 +32,11 @@ for opts in packager_opts], **treepkg_opts) -status_expansions = dict( - binary_package_created="build successful", - creating_binary_package="building binary packages", - source_package_created="source package created", - creating_source_package="creating source package", - error="error") - -def status_finished(status): - return status.status == "binary_package_created" - -def status_error(status): - return status.status == "error" - def status_class(status): """Returns the CSS class for a status""" - if status_finished(status): + if status.finished: return "finished" - elif status_error(status): + elif status.error: return "error" else: return "inprogress" @@ -69,11 +56,10 @@ def prepare_status(status): - return struct(desc=status_expansions.get(status.status, - status.status), + return struct(desc=status.status.description, start=format_time(status.start), stop=format_time(status.stop), - cls=status_class(status)) + cls=status_class(status.status)) def prepare_report(group): revisions = {}
--- a/treepkg/status.py Thu Mar 15 21:03:44 2007 +0100 +++ b/treepkg/status.py Thu Mar 15 21:12:23 2007 +0100 @@ -177,6 +177,13 @@ _magic = "TreePackagerStatus 0.0\n" - status = StringFieldDesc(default="unknown") + status = EnumFieldDesc() + status.add("creating_source_package", "creating source package") + status.add("source_package_created", "source package created") + status.add("creating_binary_package", "building binary packages") + status.add("binary_package_created", "build successful", finished=True) + status.add("error", "error", error=True) + status.add("unknown", "unknown", default=True) + start = DateFieldDesc(default=None) stop = DateFieldDesc(default=None)