Skip to content
Permalink
Browse files

Return 0/1/2 in plugin installer

cc @felixfontein

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 14, 2015
1 parent 1d17171 commit 5261df2089bfc7fb1d22a81934f3322ea079bf51
Showing with 12 additions and 11 deletions.
  1. +1 −1 nikola/plugins/command/import_wordpress.py
  2. +11 −10 nikola/plugins/command/plugin.py
@@ -75,7 +75,7 @@ def install_plugin(site, plugin_name, output_dir=None, show_install_notes=False)
options['install'] = plugin_name
options['output_dir'] = output_dir
options['show_install_notes'] = show_install_notes
if not plugin_installer.execute(options=options):
if plugin_installer.execute(options=options) > 0:
return False
# Let the plugin manager find newly installed plugins
site.plugin_manager.collectPlugins()
@@ -128,7 +128,7 @@ def _execute(self, options, args):
list_installed)].count(True)
if command_count > 1 or command_count == 0:
print(self.help())
return
return 2

if options.get('output_dir') is not None:
self.output_dir = options.get('output_dir')
@@ -159,7 +159,7 @@ def list_available(self, url):
print("------------------")
for plugin in sorted(data.keys()):
print(plugin)
return True
return 0

def list_installed(self):
plugins = []
@@ -174,7 +174,7 @@ def list_installed(self):
plugins.sort()
for name, path in plugins:
print('{0} at {1}'.format(name, path))
return True
return 0

def do_upgrade(self, url):
LOGGER.warning('This is not very smart, it just reinstalls some plugins and hopes for the best')
@@ -199,11 +199,11 @@ def do_upgrade(self, url):
break
elif tail == '':
LOGGER.error("Can't find the plugins folder for path: {0}".format(p))
return False
return 1
else:
path = tail
self.do_install(url, name)
return True
return 0

def do_install(self, url, name, show_install_notes=True):
data = self.get_json(url)
@@ -220,13 +220,13 @@ def do_install(self, url, name, show_install_notes=True):
plugin_path = utils.get_plugin_path(name)
except:
LOGGER.error("Can't find plugin " + name)
return False
return 1

utils.makedirs(self.output_dir)
dest_path = os.path.join(self.output_dir, name)
if os.path.exists(dest_path):
LOGGER.error("{0} is already installed".format(name))
return False
return 1

LOGGER.info('Copying {0} into plugins'.format(plugin_path))
shutil.copytree(plugin_path, dest_path)
@@ -272,7 +272,7 @@ def do_install(self, url, name, show_install_notes=True):
4 * ' '))
else:
print(utils.indent(fh.read(), 4 * ' '))
return True
return 0

def do_uninstall(self, name):
for plugin in self.site.plugin_manager.getAllPlugins(): # FIXME: this is repeated thrice
@@ -289,9 +289,10 @@ def do_uninstall(self, name):
if sure.lower().startswith('y'):
LOGGER.warning('Removing {0}'.format(p))
shutil.rmtree(p)
return True
return 0
return 1
LOGGER.error('Unknown plugin: {0}'.format(name))
return False
return 1

def get_json(self, url):
if self.json is None:

0 comments on commit 5261df2

Please sign in to comment.
You can’t perform that action at this time.