Skip to content

Commit 5261df2

Browse files
committedJul 14, 2015
Return 0/1/2 in plugin installer
cc @felixfontein Signed-off-by: Chris Warrick <kwpolska@gmail.com>
1 parent 1d17171 commit 5261df2

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed
 

‎nikola/plugins/command/import_wordpress.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def install_plugin(site, plugin_name, output_dir=None, show_install_notes=False)
7575
options['install'] = plugin_name
7676
options['output_dir'] = output_dir
7777
options['show_install_notes'] = show_install_notes
78-
if not plugin_installer.execute(options=options):
78+
if plugin_installer.execute(options=options) > 0:
7979
return False
8080
# Let the plugin manager find newly installed plugins
8181
site.plugin_manager.collectPlugins()

‎nikola/plugins/command/plugin.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def _execute(self, options, args):
128128
list_installed)].count(True)
129129
if command_count > 1 or command_count == 0:
130130
print(self.help())
131-
return
131+
return 2
132132

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

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

179179
def do_upgrade(self, url):
180180
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):
199199
break
200200
elif tail == '':
201201
LOGGER.error("Can't find the plugins folder for path: {0}".format(p))
202-
return False
202+
return 1
203203
else:
204204
path = tail
205205
self.do_install(url, name)
206-
return True
206+
return 0
207207

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

225225
utils.makedirs(self.output_dir)
226226
dest_path = os.path.join(self.output_dir, name)
227227
if os.path.exists(dest_path):
228228
LOGGER.error("{0} is already installed".format(name))
229-
return False
229+
return 1
230230

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

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

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

0 commit comments

Comments
 (0)
Please sign in to comment.