-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,18 +77,21 @@ def load_plugins(self, cardinal, user, channel, msg): | |
plugins.append(plugin['name']) | ||
|
||
deferred = cardinal.plugin_manager.load(plugins) | ||
|
||
def handle_results(plugins): | ||
states = {True: [], False: []} | ||
for success, plugin in plugins: | ||
for _, (success, plugin) in plugins: | ||
states[success].append(plugin) | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
johnmaguire
Author
Owner
|
||
if len(states[True]) > 0: | ||
cardinal.sendMsg(channel, "Plugins loaded succesfully: %s." % | ||
', '.join(sorted(states[True]))) | ||
cardinal.sendMsg(channel, | ||
"Plugins loaded succesfully: %s." % | ||
', '.join(sorted(states[True]))) | ||
|
||
if len(states[False]) > 0: | ||
cardinal.sendMsg(channel, "Plugins failed to load: %s." % | ||
', '.join(sorted(states[False]))) | ||
cardinal.sendMsg(channel, | ||
"Plugins failed to load: %s." % | ||
', '.join(sorted(states[False]))) | ||
|
||
deferred.addCallback(handle_results) | ||
|
||
|
@@ -117,16 +120,18 @@ def unload_plugins(self, cardinal, user, channel, msg): | |
deferred = cardinal.plugin_manager.unload(plugins) | ||
def handle_results(plugins): | ||
states = {True: [], False: []} | ||
for success, plugin in plugins: | ||
for _, (success, plugin) in plugins: | ||
states[success].append(plugin) | ||
|
||
if len(states[True]) > 0: | ||
cardinal.sendMsg(channel, "Plugins unloaded succesfully: %s." % | ||
', '.join(sorted(states[True]))) | ||
cardinal.sendMsg(channel, | ||
"Plugins unloaded succesfully: %s." % | ||
', '.join(sorted(states[True]))) | ||
|
||
if len(states[False]) > 0: | ||
cardinal.sendMsg(channel, "Unknown plugins: %s." % | ||
', '.join(sorted(states[False]))) | ||
cardinal.sendMsg(channel, | ||
"Unknown plugins: %s." % | ||
', '.join(sorted(states[False]))) | ||
|
||
deferred.addCallback(handle_results) | ||
|
||
|
@@ -185,7 +190,7 @@ def enable_plugins(self, cardinal, user, channel, msg): | |
cardinal.sendMsg("Plugin %s does not exist" % plugin) | ||
|
||
successful = [ | ||
channel for channel in channels if channel not in not_blacklisted | ||
_channel for _channel in channels if _channel not in not_blacklisted | ||
] | ||
|
||
if len(successful) > 0: | ||
|
Instead of building a second
success
state, I would rather have the callback be a failure in both cases (plugin failed to load, plugin not known before) with a different exception, and then sort them by that exception type to print them.