Skip to content
Permalink
Browse files
Using the plugin manager to get hold of the 'plugin' plugin.
  • Loading branch information
felixfontein committed Jul 12, 2015
1 parent 6a1813b commit 05d10d397f8a4719719cee642254bfc85e4649d4
Showing with 12 additions and 2 deletions.
  1. +12 −2 nikola/plugins/command/import_wordpress.py
@@ -59,8 +59,17 @@

def install_plugin(site, plugin_name, output_dir=None, show_install_notes=False):
LOGGER.notice("Installing plugin '{0}'".format(plugin_name))
plugin_installer = plugin.CommandPlugin()
plugin_installer.set_site(site)
# Get hold of the 'plugin' plugin
plugin_installer_info = site.plugin_manager.getPluginByName('plugin', 'Command')
if plugin_installer_info is None:
LOGGER.error('Internal error: cannot find the "plugin" plugin which is supposed to come with Nikola!')
return False
if not plugin_installer_info.is_activated:
# Someone might have disabled the plugin in the `conf.py` used
self.site.plugin_manager.activatePluginByName(plugin_installer_info.name)
plugin_installer_info.plugin_object.set_site(site)
plugin_installer = plugin_installer_info.plugin_object
# Try to install the requested plugin
options = {}
for option in plugin_installer.cmd_options:
options[option['name']] = option['default']
@@ -69,6 +78,7 @@ def install_plugin(site, plugin_name, output_dir=None, show_install_notes=False)
options['show_install_notes'] = show_install_notes
if not plugin_installer.execute(options=options):
return False
# Let the plugin manager find newly installed plugins
site.plugin_manager.collectPlugins()
return True

0 comments on commit 05d10d3

Please sign in to comment.