def mod_reload(name=None): if not name: output.warning("Execution from webpanel: Reload all modules", "WEBSERVER") reload.reload_all_modules(bot) return {'reload': True} else: output.warning("Execution from webpanel: Reload module %s" % str(name), "WEBSERVER") reload.reload_module(bot, str(name)) return {'reload': True}
def mod_unload(name): home = os.getcwd() name = name.strip('.py') # Get all files in modules directory tmp = os.listdir(os.path.join(home, 'modules')) modules = [] for module in tmp: if module.endswith('.pyc'): continue module = module.replace('.py', '') modules.append(module) if name not in modules: return {'success': False, 'message': 'That module doesn\'t exist'} if name in bot.unload: return {'success': False, 'message': 'Module already unloaded'} if name in bot.load: # Remove from load, and add to unload del bot.load[bot.load.index(name)] output.warning("Execution from webpanel: Unload module %s" % str(name), "WEBSERVER") bot.unload.append(name) reload.reload_all_modules(bot) return {'success': True}