Ejemplo n.º 1
0
    def run(self):
        import wsgi.views
        from utils.modules import get_activated_modules

        self.update_db()
        # Load modules
        get_activated_modules()
        self.restart_irc_bot()
        super(App, self).run()
Ejemplo n.º 2
0
def modules_view_post():
    if 'uninstall' in request.forms.keys():
        module = ModuleConfiguration.get(ModuleConfiguration.identifier == request.forms['uninstall'])
        if module.activated:
            danger(_('Module is activated.'))
        else:
            module.get_module().uninstall()
            success(_('Module uninstalled successfully.'))
    else:
        activated_modules = set([module.identifier for module in get_activated_modules()])
        deactivated_modules = set([module.identifier for module in get_deactivated_modules()])

        new_activated_modules = set(request.forms.keys())
        to_activate = new_activated_modules & deactivated_modules
        to_deactivate = activated_modules - new_activated_modules

        for identifier in to_activate:
            modules[identifier].activate()
        for identifier in to_deactivate:
            modules[identifier].deactivate()

        if to_activate or to_deactivate:
            success(_('Module changed successfully.'))
    return {
        'modules': modules,
    }
Ejemplo n.º 3
0
def upgrades_view():
    for module in get_activated_modules():
        if module.need_upgrades():
            module.run_upgrades()
            success('Module "{0}" upgraded.'.format(module.title))
    success('All upgrades done.')
    return {}
Ejemplo n.º 4
0
def need_upgrades():
    """ Avoid circular import """
    from utils.modules import get_activated_modules
    return any([module.need_upgrades() for module in get_activated_modules()])