comparison 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
comparison
equal deleted inserted replaced
38:091f99bfbe44 39:2f717f961996
39 if ctx.args.portable: 39 if ctx.args.portable:
40 # Disable pretty URLs because there's likely not going to be 40 # Disable pretty URLs because there's likely not going to be
41 # a web server to handle serving default documents. 41 # a web server to handle serving default documents.
42 ctx.app.config.set('site/pretty_urls', False) 42 ctx.app.config.set('site/pretty_urls', False)
43 43
44 baker.bake() 44 try:
45 baker.bake()
46 return 0
47 except Exception as ex:
48 logger.error(str(ex))
49 return 1
45 50
46 51
47 class ShowRecordCommand(ChefCommand): 52 class ShowRecordCommand(ChefCommand):
48 def __init__(self): 53 def __init__(self):
49 super(ShowRecordCommand, self).__init__() 54 super(ShowRecordCommand, self).__init__()
57 nargs='?') 62 nargs='?')
58 63
59 def run(self, ctx): 64 def run(self, ctx):
60 out_dir = ctx.args.output or os.path.join(ctx.app.root_dir, '_counter') 65 out_dir = ctx.args.output or os.path.join(ctx.app.root_dir, '_counter')
61 record_cache = ctx.app.cache.getCache('bake_r') 66 record_cache = ctx.app.cache.getCache('bake_r')
62 record_name = hashlib.md5(out_dir).hexdigest() + '.record' 67 record_name = hashlib.md5(out_dir.encode('utf8')).hexdigest() + '.record'
63 if not record_cache.has(record_name): 68 if not record_cache.has(record_name):
64 raise Exception("No record has been created for this output path. " 69 raise Exception("No record has been created for this output path. "
65 "Did you bake there yet?") 70 "Did you bake there yet?")
66 71
67 record = BakeRecord.load(record_cache.getCachePath(record_name)) 72 record = BakeRecord.load(record_cache.getCachePath(record_name))