Mercurial > piecrust2
view piecrust/commands/builtin/tasks.py @ 1136:5f97b5b59dfe
bake: Optimize cache handling for the baking process.
- Get rid of the 2-level pipeline runs... handle a single set of passes.
- Go back to load/render segments/layout passes for pages.
- Add descriptions of what each job batch does.
- Improve the taxonomy pipeline so it doesn't re-bake terms that don't need
to be re-baked.
- Simplify some of the code.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 23 Apr 2018 21:47:49 -0700 |
parents | 8af2ea1f5c34 |
children |
line wrap: on
line source
import os.path import logging from piecrust.commands.base import ChefCommand logger = logging.getLogger(__name__) class TasksCommand(ChefCommand): """ Command for managing and running task queues. """ def __init__(self): super().__init__() self.name = 'tasks' self.description = "Manages and runs various tasks." def setupParser(self, parser, app): subparsers = parser.add_subparsers() p = subparsers.add_parser( 'list', help="Show the list of tasks current in the queue.") p.set_defaults(sub_func=self._listTasks) p = subparsers.add_parser( 'run', help="Runs the current task queue.") p.add_argument( '-k', '--keep-queue', action='store_true', help="Don't delete the task queue files.") p.add_argument( '-t', '--task', help="Specify which task to run.") p.set_defaults(sub_func=self._runTasks) def run(self, ctx): if hasattr(ctx.args, 'sub_func'): ctx.args.sub_func(ctx) def _listTasks(self, ctx): from piecrust.tasks.base import TaskManager root_dir = ctx.app.root_dir tm = TaskManager(ctx.app) tm.getTasks() tasks = list(tm.getTasks()) logger.info("Task queue contains %d tasks" % len(tasks)) for path, task_type, task_data in tasks: logger.info(" - [%s] %s" % (task_type, os.path.relpath(path, root_dir))) def _runTasks(self, ctx): from piecrust.tasks.base import TaskManager only_task = ctx.args.task if only_task and os.path.isfile(only_task): only_task, _ = os.path.splitext(os.path.basename(only_task)) tm = TaskManager(ctx.app) tm.runQueue( only_task=only_task, clear_queue=False) # (not ctx.args.keep_queue))