diff options
| author | 2019-10-14 12:55:32 +0100 | |
|---|---|---|
| committer | 2019-10-14 12:56:04 +0100 | |
| commit | a9111c724148634486524f3744c3bbe039f3cc1d (patch) | |
| tree | aaffef8d9b6923a921c0406ca63c28ccb5b35f20 /modules/modules.py | |
| parent | refactor out chosing loadable modules in to _list_valid_modules() (diff) | |
| signature | ||
add ModuleManager.try_reload_modules(), to try reloading in a transaction
if any of the modules fails to reload, rollback and use the already loaded modules. closes #179
Diffstat (limited to 'modules/modules.py')
| -rw-r--r-- | modules/modules.py | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/modules/modules.py b/modules/modules.py index 25a2c289..cac145ba 100644 --- a/modules/modules.py +++ b/modules/modules.py @@ -71,26 +71,11 @@ class Module(ModuleManager.BaseModule): :help: Reload all modules :permission: reload-all-modules """ - success = [] - fail = [] - for name in list(self.bot.modules.modules.keys()): - try: - self.bot.modules.unload_module(name) - except ModuleManager.ModuleWarning: - continue - except: - fail.append(name) - load_success, load_fail = self.bot.load_modules(safe=True) - success.extend(load_success) - fail.extend(load_fail) - - if success and fail: - event["stdout"].write("Reloaded %d modules, %d failed" % ( - len(success), len(fail))) - elif fail: - event["stdout"].write("Failed to reload all modules") + result = self.bot.try_reload_modules() + if result.success: + event["stdout"].write(result.message) else: - event["stdout"].write("Reloaded %d modules" % len(success)) + event["stderr"].write(result.message) @utils.hook("received.command.enablemodule", min_args=1) def enable(self, event): |
