diff piecrust/processing/tree.py @ 120:133845647083

Better error management and removal support in baking/processing. * Baker and processor pipeline now store errors in their records. * They also support deleting output files that are no longer valid. * The basic transitional record class implements more boilerplate code. * The processor pipeline is run from the `bake` command directly. * New unit tests. * Unit test mocking now mocks `os.remove` too.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 09 Nov 2014 14:46:23 -0800
parents 6827dcc9d3fb
children 3834e2ef0cf2
line wrap: on
line diff
--- a/piecrust/processing/tree.py	Wed Oct 29 08:19:58 2014 -0700
+++ b/piecrust/processing/tree.py	Sun Nov 09 14:46:23 2014 -0800
@@ -2,6 +2,7 @@
 import time
 import os.path
 import logging
+from piecrust.chefutil import format_timed
 
 
 logger = logging.getLogger(__name__)
@@ -150,7 +151,8 @@
                             start_time, "(bypassing structured processing)"))
                 return True
             except Exception as e:
-                raise Exception("Error processing: %s" % node.path) from e
+                raise ProcessingTreeError("Error processing: %s" %
+                        node.path) from e
 
         # All outputs of a node must go to the same directory, so we can get
         # the output directory off of the first output.
@@ -239,7 +241,9 @@
                 node.setState(STATE_CLEAN, False)
 
         state = "dirty" if node.state == STATE_DIRTY else "clean"
-        logger.debug(format_timed(start_time, "Computed node dirtyness: %s" % state, node.level))
+        logger.debug(format_timed(start_time,
+                                  "Computed node dirtyness: %s" % state,
+                                  indent_level=node.level))
 
     def _getNodeBaseDir(self, node):
         if node.level == 0:
@@ -267,10 +271,3 @@
         for o in node.outputs:
             print_node(o, None, True)
 
-
-def format_timed(start_time, message, indent_level=0):
-    end_time = time.clock()
-    indent = indent_level * '  '
-    build_time = '{0:8.1f} ms'.format((end_time - start_time) / 1000.0)
-    return "%s[%s] %s" % (indent, build_time, message)
-