Mercurial > piecrust2
annotate piecrust/commands/builtin/baking.py @ 215:a47580a0955b
bake: Better error handling for the processing pipeline.
Pipeline jobs now keep track of whether they've seen any errors. This is
aggregated into an overall "success" flag for the processing record. Also, jobs
keep going as long as there's no critical (i.e. internal) failure happening.
Errors raised by processors are also better tracked: the actual processor that
failed, along with the input file, are tracks in the processing record.
The `bake` command returns a failure exit code if processing saw any error.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 31 Jan 2015 17:08:02 -0800 |
parents | e725af1d48fb |
children | 1f4c3dae1fe8 |
rev | line source |
---|---|
121 | 1 import time |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 import os.path |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 import logging |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 import hashlib |
92
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
5 import fnmatch |
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
6 import datetime |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
7 from piecrust.baking.baker import Baker |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
8 from piecrust.baking.records import BakeRecord |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
9 from piecrust.chefutil import format_timed |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
10 from piecrust.commands.base import ChefCommand |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
11 from piecrust.processing.base import ProcessorPipeline |
194
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
12 from piecrust.processing.records import ( |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
13 ProcessorPipelineRecord, FLAG_OVERRIDEN) |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
14 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
15 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
16 logger = logging.getLogger(__name__) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
17 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
18 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
19 class BakeCommand(ChefCommand): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
20 def __init__(self): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
21 super(BakeCommand, self).__init__() |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
22 self.name = 'bake' |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
23 self.description = "Bakes your website into static HTML files." |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
24 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
25 def setupParser(self, parser, app): |
192
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
26 parser.add_argument( |
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
27 '-o', '--output', |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
28 help="The directory to put all the baked HTML files into " |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
29 "(defaults to `_counter`)") |
192
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
30 parser.add_argument( |
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
31 '-f', '--force', |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
32 help="Force re-baking the entire website.", |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
33 action='store_true') |
192
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
34 parser.add_argument( |
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
35 '--no-assets', |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
36 help="Don't process assets (only pages).", |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
37 action='store_true') |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
38 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
39 def run(self, ctx): |
127
bc63dc20baa0
Fix how we pass the out directory to the baking modules.
Ludovic Chabant <ludovic@chabant.com>
parents:
121
diff
changeset
|
40 out_dir = (ctx.args.output or |
bc63dc20baa0
Fix how we pass the out directory to the baking modules.
Ludovic Chabant <ludovic@chabant.com>
parents:
121
diff
changeset
|
41 os.path.join(ctx.app.root_dir, '_counter')) |
bc63dc20baa0
Fix how we pass the out directory to the baking modules.
Ludovic Chabant <ludovic@chabant.com>
parents:
121
diff
changeset
|
42 |
215
a47580a0955b
bake: Better error handling for the processing pipeline.
Ludovic Chabant <ludovic@chabant.com>
parents:
205
diff
changeset
|
43 success = True |
121 | 44 start_time = time.clock() |
39
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
45 try: |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
46 # Bake the site sources. |
215
a47580a0955b
bake: Better error handling for the processing pipeline.
Ludovic Chabant <ludovic@chabant.com>
parents:
205
diff
changeset
|
47 success = success & self._bakeSources(ctx, out_dir) |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
48 |
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
49 # Bake the assets. |
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
50 if not ctx.args.no_assets: |
215
a47580a0955b
bake: Better error handling for the processing pipeline.
Ludovic Chabant <ludovic@chabant.com>
parents:
205
diff
changeset
|
51 success = success & self._bakeAssets(ctx, out_dir) |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
52 |
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
53 # All done. |
192
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
54 logger.info('-------------------------') |
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
55 logger.info(format_timed(start_time, 'done baking')) |
215
a47580a0955b
bake: Better error handling for the processing pipeline.
Ludovic Chabant <ludovic@chabant.com>
parents:
205
diff
changeset
|
56 return 0 if success else 1 |
39
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
57 except Exception as ex: |
43 | 58 if ctx.app.debug: |
59 logger.exception(ex) | |
60 else: | |
61 logger.error(str(ex)) | |
39
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
62 return 1 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
63 |
127
bc63dc20baa0
Fix how we pass the out directory to the baking modules.
Ludovic Chabant <ludovic@chabant.com>
parents:
121
diff
changeset
|
64 def _bakeSources(self, ctx, out_dir): |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
65 baker = Baker( |
127
bc63dc20baa0
Fix how we pass the out directory to the baking modules.
Ludovic Chabant <ludovic@chabant.com>
parents:
121
diff
changeset
|
66 ctx.app, out_dir, |
205
e725af1d48fb
bake: Changes in how assets directories are configured.
Ludovic Chabant <ludovic@chabant.com>
parents:
201
diff
changeset
|
67 force=ctx.args.force) |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
68 baker.bake() |
215
a47580a0955b
bake: Better error handling for the processing pipeline.
Ludovic Chabant <ludovic@chabant.com>
parents:
205
diff
changeset
|
69 return True |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
70 |
127
bc63dc20baa0
Fix how we pass the out directory to the baking modules.
Ludovic Chabant <ludovic@chabant.com>
parents:
121
diff
changeset
|
71 def _bakeAssets(self, ctx, out_dir): |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
72 proc = ProcessorPipeline( |
205
e725af1d48fb
bake: Changes in how assets directories are configured.
Ludovic Chabant <ludovic@chabant.com>
parents:
201
diff
changeset
|
73 ctx.app, out_dir, |
e725af1d48fb
bake: Changes in how assets directories are configured.
Ludovic Chabant <ludovic@chabant.com>
parents:
201
diff
changeset
|
74 force=ctx.args.force) |
215
a47580a0955b
bake: Better error handling for the processing pipeline.
Ludovic Chabant <ludovic@chabant.com>
parents:
205
diff
changeset
|
75 record = proc.run() |
a47580a0955b
bake: Better error handling for the processing pipeline.
Ludovic Chabant <ludovic@chabant.com>
parents:
205
diff
changeset
|
76 return record.success |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
77 |
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
78 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
79 class ShowRecordCommand(ChefCommand): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
80 def __init__(self): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
81 super(ShowRecordCommand, self).__init__() |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
82 self.name = 'showrecord' |
192
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
83 self.description = ("Shows the bake record for a given output " |
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
84 "directory.") |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
85 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
86 def setupParser(self, parser, app): |
192
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
87 parser.add_argument( |
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
88 '-o', '--output', |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
89 help="The output directory for which to show the bake record " |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
90 "(defaults to `_counter`)", |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
91 nargs='?') |
192
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
92 parser.add_argument( |
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
93 '-p', '--path', |
92
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
94 help="A pattern that will be used to filter the relative path " |
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
95 "of entries to show.") |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
96 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
97 def run(self, ctx): |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
98 out_dir = ctx.args.output or os.path.join(ctx.app.root_dir, '_counter') |
194
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
99 record_name = (hashlib.md5(out_dir.encode('utf8')).hexdigest() + |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
100 '.record') |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
101 |
92
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
102 pattern = None |
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
103 if ctx.args.path: |
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
104 pattern = '*%s*' % ctx.args.path.strip('*') |
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
105 |
194
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
106 record_cache = ctx.app.cache.getCache('baker') |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
107 if not record_cache.has(record_name): |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
108 raise Exception("No record has been created for this output path. " |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
109 "Did you bake there yet?") |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
110 |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
111 record = BakeRecord.load(record_cache.getCachePath(record_name)) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
112 logging.info("Bake record for: %s" % record.out_dir) |
92
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
113 logging.info("Last baked: %s" % |
192
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
114 datetime.datetime.fromtimestamp(record.bake_time)) |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
115 logging.info("Entries:") |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
116 for entry in record.entries: |
92
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
117 if pattern: |
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
118 if not fnmatch.fnmatch(entry.rel_path, pattern): |
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
119 continue |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
120 logging.info(" - ") |
192
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
121 logging.info(" path: %s" % entry.rel_path) |
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
122 logging.info(" spec: %s:%s" % (entry.source_name, |
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
123 entry.rel_path)) |
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
124 logging.info(" taxonomy: %s:%s" % (entry.taxonomy_name, |
4c0ab0b044fe
cosmetic: Fix some PEP8 issues.
Ludovic Chabant <ludovic@chabant.com>
parents:
127
diff
changeset
|
125 entry.taxonomy_term)) |
92
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
126 logging.info(" config: %s" % entry.config) |
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
127 logging.info(" out URLs: %s" % entry.out_uris) |
193
c2acf5f31936
showrecord: Show relative paths.
Ludovic Chabant <ludovic@chabant.com>
parents:
192
diff
changeset
|
128 logging.info(" out paths: %s" % [os.path.relpath(p, out_dir) |
c2acf5f31936
showrecord: Show relative paths.
Ludovic Chabant <ludovic@chabant.com>
parents:
192
diff
changeset
|
129 for p in entry.out_paths]) |
92
0dd43c5f5484
More options for the `showrecord` command.
Ludovic Chabant <ludovic@chabant.com>
parents:
45
diff
changeset
|
130 logging.info(" used srcs: %s" % entry.used_source_names) |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
131 if entry.errors: |
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
92
diff
changeset
|
132 logging.error(" errors: %s" % entry.errors) |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
133 |
194
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
134 record_cache = ctx.app.cache.getCache('proc') |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
135 if not record_cache.has(record_name): |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
136 return |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
137 |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
138 record = ProcessorPipelineRecord.load( |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
139 record_cache.getCachePath(record_name)) |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
140 logging.info("") |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
141 logging.info("Processing record for: %s" % record.out_dir) |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
142 logging.info("Last baked: %s" % |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
143 datetime.datetime.fromtimestamp(record.process_time)) |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
144 logging.info("Entries:") |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
145 for entry in record.entries: |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
146 if pattern: |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
147 if not fnmatch.fnmatch(entry.rel_input, pattern): |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
148 continue |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
149 flags = '' |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
150 if entry.flags & FLAG_OVERRIDEN: |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
151 flags += 'overriden' |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
152 logger.info(" - ") |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
153 logger.info(" path: %s" % entry.rel_input) |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
154 logger.info(" out paths: %s" % entry.rel_outputs) |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
155 logger.info(" flags: %s" % flags) |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
156 logger.info(" proc tree: %s" % format_proc_tree( |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
157 entry.proc_tree, 14*' ')) |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
158 if entry.errors: |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
159 logger.error(" errors: %s" % entry.errors) |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
160 |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
161 |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
162 def format_proc_tree(tree, margin='', level=0): |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
163 name, children = tree |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
164 res = '%s%s%s' % (margin if level > 0 else '', level * ' ', name) |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
165 if children: |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
166 for c in children: |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
167 res += format_proc_tree(c, margin, level + 1) |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
168 return res |
5d8351cb32d8
showrecord: Also show the pipeline record.
Ludovic Chabant <ludovic@chabant.com>
parents:
193
diff
changeset
|
169 |