Mercurial > piecrust2
comparison piecrust/commands/builtin/baking.py @ 701:066d6156525c
showrecord: Don't print the record when you just want the stats.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 16 Apr 2016 22:48:57 -0700 |
parents | 33ab9badfd7a |
children | ab5c6a8ae90a |
comparison
equal
deleted
inserted
replaced
700:76a799eae824 | 701:066d6156525c |
---|---|
211 | 211 |
212 out_pattern = None | 212 out_pattern = None |
213 if ctx.args.out: | 213 if ctx.args.out: |
214 out_pattern = '*%s*' % ctx.args.out.strip('*') | 214 out_pattern = '*%s*' % ctx.args.out.strip('*') |
215 | 215 |
216 bake_rec = None | 216 if not ctx.args.show_stats: |
217 if not ctx.args.assets_only: | 217 if not ctx.args.assets_only: |
218 bake_rec = self._showBakeRecord( | 218 self._showBakeRecord( |
219 ctx, record_name, pattern, out_pattern) | 219 ctx, record_name, pattern, out_pattern) |
220 proc_rec = None | 220 if not ctx.args.html_only: |
221 if not ctx.args.html_only: | 221 self._showProcessingRecord( |
222 proc_rec = self._showProcessingRecord( | 222 ctx, record_name, pattern, out_pattern) |
223 ctx, record_name, pattern, out_pattern) | |
224 | 223 |
225 if ctx.args.show_stats: | 224 if ctx.args.show_stats: |
226 stats = {} | 225 stats = {} |
226 bake_rec = self._getBakeRecord(ctx, record_name) | |
227 if bake_rec: | 227 if bake_rec: |
228 _merge_stats(bake_rec.stats, stats) | 228 _merge_stats(bake_rec.stats, stats) |
229 proc_rec = self._getProcessingRecord(ctx, record_name) | |
229 if proc_rec: | 230 if proc_rec: |
230 _merge_stats(proc_rec.stats, stats) | 231 _merge_stats(proc_rec.stats, stats) |
231 _show_stats(stats, full=True) | 232 _show_stats(stats, full=False) |
232 | 233 |
233 def _showBakeRecord(self, ctx, record_name, pattern, out_pattern): | 234 def _getBakeRecord(self, ctx, record_name): |
234 # Show the bake record. | |
235 record_cache = ctx.app.cache.getCache('baker') | 235 record_cache = ctx.app.cache.getCache('baker') |
236 if not record_cache.has(record_name): | 236 if not record_cache.has(record_name): |
237 logger.warning( | 237 logger.warning( |
238 "No page bake record has been created for this output " | 238 "No page bake record has been created for this output " |
239 "path.") | 239 "path.") |
240 return None | 240 return None |
241 | 241 |
242 record = BakeRecord.load(record_cache.getCachePath(record_name)) | 242 record = BakeRecord.load(record_cache.getCachePath(record_name)) |
243 return record | |
244 | |
245 def _showBakeRecord(self, ctx, record_name, pattern, out_pattern): | |
246 record = self._getBakeRecord(ctx, record_name) | |
247 | |
243 logging.info("Bake record for: %s" % record.out_dir) | 248 logging.info("Bake record for: %s" % record.out_dir) |
244 logging.info("From: %s" % record_name) | 249 logging.info("From: %s" % record_name) |
245 logging.info("Last baked: %s" % | 250 logging.info("Last baked: %s" % |
246 datetime.datetime.fromtimestamp(record.bake_time)) | 251 datetime.datetime.fromtimestamp(record.bake_time)) |
247 if record.success: | 252 if record.success: |
328 ri.used_taxonomy_terms])) | 333 ri.used_taxonomy_terms])) |
329 | 334 |
330 if sub.errors: | 335 if sub.errors: |
331 logging.error(" errors: %s" % sub.errors) | 336 logging.error(" errors: %s" % sub.errors) |
332 | 337 |
333 return record | 338 def _getProcessingRecord(self, ctx, record_name): |
334 | |
335 def _showProcessingRecord(self, ctx, record_name, pattern, out_pattern): | |
336 record_cache = ctx.app.cache.getCache('proc') | 339 record_cache = ctx.app.cache.getCache('proc') |
337 if not record_cache.has(record_name): | 340 if not record_cache.has(record_name): |
338 logger.warning( | 341 logger.warning( |
339 "No asset processing record has been created for this " | 342 "No asset processing record has been created for this " |
340 "output path.") | 343 "output path.") |
341 return None | 344 return None |
342 | 345 |
343 # Show the pipeline record. | |
344 record = ProcessorPipelineRecord.load( | 346 record = ProcessorPipelineRecord.load( |
345 record_cache.getCachePath(record_name)) | 347 record_cache.getCachePath(record_name)) |
348 return record | |
349 | |
350 def _showProcessingRecord(self, ctx, record_name, pattern, out_pattern): | |
351 record = self._getProcessingRecord(ctx, record_name) | |
352 if record is None: | |
353 return | |
354 | |
346 logging.info("") | 355 logging.info("") |
347 logging.info("Processing record for: %s" % record.out_dir) | 356 logging.info("Processing record for: %s" % record.out_dir) |
348 logging.info("Last baked: %s" % | 357 logging.info("Last baked: %s" % |
349 datetime.datetime.fromtimestamp(record.process_time)) | 358 datetime.datetime.fromtimestamp(record.process_time)) |
350 if record.success: | 359 if record.success: |
376 entry.proc_tree, 14*' ')) | 385 entry.proc_tree, 14*' ')) |
377 | 386 |
378 if entry.errors: | 387 if entry.errors: |
379 logger.error(" errors: %s" % entry.errors) | 388 logger.error(" errors: %s" % entry.errors) |
380 | 389 |
381 return record | |
382 | |
383 | 390 |
384 def _join(items, sep=', ', text_if_none='none'): | 391 def _join(items, sep=', ', text_if_none='none'): |
385 if items: | 392 if items: |
386 return sep.join(items) | 393 return sep.join(items) |
387 return text_if_none | 394 return text_if_none |