Mercurial > piecrust2
comparison piecrust/commands/builtin/baking.py @ 221:f82262f59600
bake: Fix processing record bugs and error logging for external processes.
Fix problems with processing records not being collapsed correctly.
Make it possible to capture external processes' `stderr` output.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 03 Feb 2015 08:21:43 -0800 |
parents | 84e2bc2d16cb |
children | f0fc2a9d3191 |
comparison
equal
deleted
inserted
replaced
220:84e2bc2d16cb | 221:f82262f59600 |
---|---|
8 from piecrust.baking.records import BakeRecord | 8 from piecrust.baking.records import BakeRecord |
9 from piecrust.chefutil import format_timed | 9 from piecrust.chefutil import format_timed |
10 from piecrust.commands.base import ChefCommand | 10 from piecrust.commands.base import ChefCommand |
11 from piecrust.processing.base import ProcessorPipeline | 11 from piecrust.processing.base import ProcessorPipeline |
12 from piecrust.processing.records import ( | 12 from piecrust.processing.records import ( |
13 ProcessorPipelineRecord, FLAG_OVERRIDEN) | 13 ProcessorPipelineRecord, |
14 FLAG_PREPARED, FLAG_PROCESSED, FLAG_OVERRIDEN, | |
15 FLAG_BYPASSED_STRUCTURED_PROCESSING) | |
14 | 16 |
15 | 17 |
16 logger = logging.getLogger(__name__) | 18 logger = logging.getLogger(__name__) |
17 | 19 |
18 | 20 |
159 logging.info("Entries:") | 161 logging.info("Entries:") |
160 for entry in record.entries: | 162 for entry in record.entries: |
161 if pattern: | 163 if pattern: |
162 if not fnmatch.fnmatch(entry.rel_input, pattern): | 164 if not fnmatch.fnmatch(entry.rel_input, pattern): |
163 continue | 165 continue |
164 flags = '' | 166 flags = [] |
167 if entry.flags & FLAG_PREPARED: | |
168 flags.append('prepared') | |
169 if entry.flags & FLAG_PROCESSED: | |
170 flags.append('processed') | |
165 if entry.flags & FLAG_OVERRIDEN: | 171 if entry.flags & FLAG_OVERRIDEN: |
166 flags += 'overriden' | 172 flags.append('overriden') |
173 if entry.flags & FLAG_BYPASSED_STRUCTURED_PROCESSING: | |
174 flags.append('external') | |
167 logger.info(" - ") | 175 logger.info(" - ") |
168 logger.info(" path: %s" % entry.rel_input) | 176 logger.info(" path: %s" % entry.rel_input) |
169 logger.info(" out paths: %s" % entry.rel_outputs) | 177 logger.info(" out paths: %s" % entry.rel_outputs) |
170 logger.info(" flags: %s" % flags) | 178 logger.info(" flags: %s" % flags) |
171 logger.info(" proc tree: %s" % format_proc_tree( | 179 logger.info(" proc tree: %s" % format_proc_tree( |
174 logger.error(" errors: %s" % entry.errors) | 182 logger.error(" errors: %s" % entry.errors) |
175 | 183 |
176 | 184 |
177 def format_proc_tree(tree, margin='', level=0): | 185 def format_proc_tree(tree, margin='', level=0): |
178 name, children = tree | 186 name, children = tree |
179 res = '%s%s%s' % (margin if level > 0 else '', level * ' ', name) | 187 res = '%s%s+ %s\n' % (margin if level > 0 else '', level * ' ', name) |
180 if children: | 188 if children: |
181 for c in children: | 189 for c in children: |
182 res += format_proc_tree(c, margin, level + 1) | 190 res += format_proc_tree(c, margin, level + 1) |
183 return res | 191 return res |
184 | 192 |