Mercurial > piecrust2
changeset 127:bc63dc20baa0
Fix how we pass the out directory to the baking modules.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 14 Nov 2014 22:47:18 +0100 |
parents | e5cba2622d26 |
children | 28444014ce7d |
files | piecrust/baking/baker.py piecrust/commands/builtin/baking.py |
diffstat | 2 files changed, 15 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/piecrust/baking/baker.py Fri Nov 14 22:46:16 2014 +0100 +++ b/piecrust/baking/baker.py Fri Nov 14 22:47:18 2014 +0100 @@ -208,8 +208,9 @@ except Exception as ex: if self.app.debug: logger.exception(ex) - raise BakingError("Error baking page '%s' for URL '%s'." % - (page.ref_spec, uri)) from ex + page_rel_path = os.path.relpath(page.path, self.app.root_dir) + raise BakingError("%s: error baking '%s'." % + (page_rel_path, uri)) from ex # Copy page assets. if (cur_sub == 1 and self.copy_assets and @@ -264,10 +265,11 @@ class Baker(object): - def __init__(self, app, out_dir=None, force=False, portable=False, + def __init__(self, app, out_dir, force=False, portable=False, no_assets=False, num_workers=4): + assert app and out_dir self.app = app - self.out_dir = out_dir or os.path.join(app.root_dir, '_counter') + self.out_dir = out_dir self.force = force self.portable = portable self.no_assets = no_assets
--- a/piecrust/commands/builtin/baking.py Fri Nov 14 22:46:16 2014 +0100 +++ b/piecrust/commands/builtin/baking.py Fri Nov 14 22:47:18 2014 +0100 @@ -40,14 +40,17 @@ # a web server to handle serving default documents. ctx.app.config.set('site/pretty_urls', False) + out_dir = (ctx.args.output or + os.path.join(ctx.app.root_dir, '_counter')) + start_time = time.clock() try: # Bake the site sources. - self._bakeSources(ctx) + self._bakeSources(ctx, out_dir) # Bake the assets. if not ctx.args.no_assets: - self._bakeAssets(ctx) + self._bakeAssets(ctx, out_dir) # All done. logger.info('-------------------------'); @@ -60,25 +63,24 @@ logger.error(str(ex)) return 1 - def _bakeSources(self, ctx): + def _bakeSources(self, ctx, out_dir): num_workers = ctx.app.config.get('baker/workers') or 4 baker = Baker( - ctx.app, - out_dir=ctx.args.output, + ctx.app, out_dir, force=ctx.args.force, portable=ctx.args.portable, no_assets=ctx.args.no_assets, num_workers=num_workers) baker.bake() - def _bakeAssets(self, ctx): + def _bakeAssets(self, ctx, out_dir): mounts = ctx.app.assets_dirs baker_params = ctx.app.config.get('baker') or {} skip_patterns = baker_params.get('skip_patterns') force_patterns = baker_params.get('force_patterns') num_workers = ctx.app.config.get('baker/workers') or 4 proc = ProcessorPipeline( - ctx.app, mounts, ctx.args.output, + ctx.app, mounts, out_dir, force=ctx.args.force, skip_patterns=skip_patterns, force_patterns=force_patterns,