Mercurial > piecrust2
view piecrust/commands/builtin/plugins.py @ 411:e7b865f8f335
bake: Enable multiprocess baking.
Baking is now done by running a worker per CPU, and sending jobs to them.
This changes several things across the codebase:
* Ability to not cache things related to pages other than the 'main' page
(i.e. the page at the bottom of the execution stack).
* Decouple the baking process from the bake records, so only the main process
keeps track (and modifies) the bake record.
* Remove the need for 'batch page getters' and loading a page directly from
the page factories.
There are various smaller changes too included here, including support for
scope performance timers that are saved with the bake record and can be
printed out to the console. Yes I got carried away.
For testing, the in-memory 'mock' file-system doesn't work anymore, since
we're spawning processes, so this is replaced by a 'tmpfs' file-system which
is saved in temporary files on disk and deleted after tests have run.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 12 Jun 2015 17:09:19 -0700 |
parents | 9ae23409d6e9 |
children | f7ddd730c08d |
line wrap: on
line source
import logging from piecrust.commands.base import ChefCommand logger = logging.getLogger(__name__) class PluginsCommand(ChefCommand): def __init__(self): super(PluginsCommand, self).__init__() self.name = 'plugins' self.description = "Manage the plugins for the current website." def setupParser(self, parser, app): # Don't setup anything if this is a null app # (for when `chef` is run from outside a website) if app.root_dir is None: return subparsers = parser.add_subparsers() p = subparsers.add_parser( 'list', help="Lists the plugins installed in the current website.") p.add_argument( '-a', '--all', action='store_true', help=("Also list all the available plugins for the " "current environment. The installed one will have an " "asterix (*).")) p.set_defaults(sub_func=self._listPlugins) def checkedRun(self, ctx): if not hasattr(ctx.args, 'sub_func'): ctx.parser.parse_args(['plugins', '--help']) return ctx.args.sub_func(ctx) def _listPlugins(self, ctx): names = {} installed_suffix = '' if ctx.args.all: import pip prefix = 'PieCrust-' installed_packages = pip.get_installed_distributions() for plugin in installed_packages: if not plugin.project_name.startswith(prefix): continue name = plugin.project_name[len(prefix):] names[name] = False installed_suffix = '*' for plugin in ctx.app.plugin_loader.plugins: names[plugin.name] = True for name, inst in names.items(): logger.info("%s%s" % (name, installed_suffix if inst else ''))