Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 05d10d3

Browse files
committedJul 12, 2015
Using the plugin manager to get hold of the 'plugin' plugin.
1 parent 6a1813b commit 05d10d3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed
 

‎nikola/plugins/command/import_wordpress.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,17 @@
5959

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

0 commit comments

Comments
 (0)
Please sign in to comment.