diff piecrust/commands/builtin/baking.py @ 39:2f717f961996

Better error reporting and cache validation. Fix the processor pipeline in the preview server. Move the `pages` route to first position.
author Ludovic Chabant <ludovic@chabant.com>
date Thu, 21 Aug 2014 22:28:22 -0700
parents f485ba500df3
children f14889d6b067
line wrap: on
line diff
--- a/piecrust/commands/builtin/baking.py	Thu Aug 21 10:56:17 2014 -0700
+++ b/piecrust/commands/builtin/baking.py	Thu Aug 21 22:28:22 2014 -0700
@@ -41,7 +41,12 @@
             # a web server to handle serving default documents.
             ctx.app.config.set('site/pretty_urls', False)
 
-        baker.bake()
+        try:
+            baker.bake()
+            return 0
+        except Exception as ex:
+            logger.error(str(ex))
+            return 1
 
 
 class ShowRecordCommand(ChefCommand):
@@ -59,7 +64,7 @@
     def run(self, ctx):
         out_dir = ctx.args.output or os.path.join(ctx.app.root_dir, '_counter')
         record_cache = ctx.app.cache.getCache('bake_r')
-        record_name = hashlib.md5(out_dir).hexdigest() + '.record'
+        record_name = hashlib.md5(out_dir.encode('utf8')).hexdigest() + '.record'
         if not record_cache.has(record_name):
             raise Exception("No record has been created for this output path. "
                             "Did you bake there yet?")