changeset 16:7c55f3879c4d

Use the new status class and report start/stop time too
author Bernhard Herzog <bh@intevation.de>
date Fri, 09 Mar 2007 19:39:13 +0100
parents 667ae96b50f7
children 6ced445aa090 d5c24cfce05e
files reportstatus.py treepkg/packager.py
diffstat 2 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/reportstatus.py	Fri Mar 09 19:38:46 2007 +0100
+++ b/reportstatus.py	Fri Mar 09 19:39:13 2007 +0100
@@ -30,6 +30,8 @@
                           **treepkg_opts)
     for line in group.get_package_lines():
         for revision in line.get_revisions():
-            print line.name, revision.revision, revision.status.get()
+            print line.name, revision.revision, revision.status.status
+            print "    start:", revision.status.start
+            print "     stop:", revision.status.stop
 
 main()
--- a/treepkg/packager.py	Fri Mar 09 19:38:46 2007 +0100
+++ b/treepkg/packager.py	Fri Mar 09 19:39:13 2007 +0100
@@ -13,10 +13,12 @@
 import logging
 import shutil
 import traceback
+import datetime
 
 import util
 import subversion
 import run
+import status
 
 
 def _filenameproperty(relative_dir):
@@ -152,9 +154,9 @@
         """
         util.ensure_directory(self.work_dir)
         try:
-            self.status.set("creating_source_package")
+            self.status.status = "creating_source_package"
             self.do_package()
-            self.status.set("source_package_created")
+            self.status.status = "source_package_created"
         finally:
             logging.info("Removing workdir %r", self.work_dir)
             shutil.rmtree(self.work_dir)
@@ -180,13 +182,13 @@
         self.logfile = logfile
 
     def package(self):
-        self.status.set("creating_binary_package")
+        self.status.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.set("binary_package_created")
+        self.status.status = "binary_package_created"
 
 
 class RevisionPackager(object):
@@ -198,7 +200,7 @@
         self.pkg_line = pkg_line
         self.revision = revision
         self.base_dir = self.pkg_line.pkg_dir_for_revision(self.revision, 1)
-        self.status = util.StatusFile(os.path.join(self.base_dir, "status"))
+        self.status = status.Status(os.path.join(self.base_dir, "status"))
 
     work_dir = _filenameproperty("work")
     binary_dir = _filenameproperty("binary")
@@ -212,6 +214,8 @@
 
     def package(self):
         try:
+            util.ensure_directory(self.work_dir)
+            self.status.start = datetime.datetime.utcnow()
             src_packager = self.source_packager_cls(self.pkg_line, self.status,
                                                     self.work_dir, self.src_dir,
                                                     self.revision)
@@ -226,8 +230,10 @@
                                                     os.path.join(self.base_dir,
                                                                  "build.log"))
             bin_packager.package()
+            self.status.stop = datetime.datetime.utcnow()
         except:
-            self.status.set("failed", traceback.format_exc())
+            self.status.status = "error"
+            self.status.stop = datetime.datetime.utcnow()
             raise
 
     def remove_package_dir(self):
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)