Esempio n. 1
0
def enable_plugin(plugin):
    plugin = get_plugin_from_all(plugin)
    if not plugin.enabled:
        plugin_dir = os.path.join(
            os.path.abspath(os.path.dirname(os.path.dirname(__file__))), "plugins", plugin.identifier
        )

        disabled_file = os.path.join(plugin_dir, "DISABLED")

        try:
            if os.path.exists(disabled_file):
                os.remove(disabled_file)
                flash(_("Plugin is enabled. Please reload your app."), "success")
            else:
                flash(_("Plugin is already enabled. Please reload  your app."), "warning")

        except OSError:
            flash(
                _(
                    "If you are using a host which doesn't support writting "
                    "on the disk, this won't work - than you need to delete "
                    "the 'DISABLED' file by yourself."
                ),
                "danger",
            )

    else:
        flash(_("Couldn't enable Plugin."), "danger")

    return redirect(url_for("management.plugins"))
Esempio n. 2
0
def enable_plugin(plugin):
    plugin = get_plugin_from_all(plugin)
    if not plugin.enabled:
        plugin_dir = os.path.join(
            os.path.abspath(os.path.dirname(os.path.dirname(__file__))),
            "plugins", plugin.identifier)

        disabled_file = os.path.join(plugin_dir, "DISABLED")

        try:
            if os.path.exists(disabled_file):
                os.remove(disabled_file)
                flash(_("Plugin is enabled. Please reload your app."),
                      "success")
            else:
                flash(_("Plugin is already enabled. Please reload  your app."),
                      "warning")

        except OSError:
            flash(
                _("If you are using a host which doesn't support writting "
                  "on the disk, this won't work - than you need to delete "
                  "the 'DISABLED' file by yourself."), "danger")

    else:
        flash(_("Couldn't enable Plugin."), "danger")

    return redirect(url_for("management.plugins"))
Esempio n. 3
0
def _disable_plugins():
    plugin = request.args.get('disableplugins', 0, type=str)
    pluginsmanager = PluginManager()
    try:
        pluginsmanager.disable_plugins([get_plugin_from_all(plugin)])
    except KeyError:
        pass
    return jsonify(success=True)
Esempio n. 4
0
def uninstall_plugin(plugin_identifier):
    """Uninstalls a plugin from FlaskBB."""
    validate_plugin(plugin_identifier)
    plugin = get_plugin_from_all(plugin_identifier)
    click.secho("[+] Uninstalling plugin {}...".format(plugin.name), fg="cyan")
    try:
        plugin_manager.uninstall_plugins([plugin])
    except AttributeError:
        pass
Esempio n. 5
0
def upgrade_plugin(plugin_identifier):
    """Uninstalls a plugin from FlaskBB."""
    validate_plugin(plugin_identifier)
    plugin = get_plugin_from_all(plugin_identifier)
    click.secho("[+] Upgrading plugin {}...".format(plugin.name), fg="cyan")
    try:
        plugin.upgrade_database()
    except AttributeError:
        pass
Esempio n. 6
0
def uninstall_plugin(plugin_identifier):
    """Uninstalls a plugin from FlaskBB."""
    validate_plugin(plugin_identifier)
    plugin = get_plugin_from_all(plugin_identifier)
    click.secho("[+] Uninstalling plugin {}...".format(plugin.name), fg="cyan")
    try:
        plugin_manager.uninstall_plugins([plugin])
    except AttributeError:
        pass
Esempio n. 7
0
def install_plugin(plugin_identifier):
    """Installs a new plugin."""
    validate_plugin(plugin_identifier)
    plugin = get_plugin_from_all(plugin_identifier)
    click.secho("[+] Installing plugin {}...".format(plugin.name), fg="cyan")
    try:
        plugin_manager.install_plugins([plugin])
    except Exception as e:
        click.secho("[-] Couldn't install plugin because of following "
                    "exception: \n{}".format(e), fg="red")
Esempio n. 8
0
def migrate_plugin(plugin_identifier):
    """Installs a new plugin."""
    validate_plugin(plugin_identifier)
    plugin = get_plugin_from_all(plugin_identifier)
    click.secho("[+] Updating plugin migrations{}...".format(plugin.name), fg="cyan")
    try:
        plugin.migrate()
    except Exception as e:
        click.secho("[-] Couldn't generate migrations for plugin because of following "
                    "exception: \n{}".format(e), fg="red")
Esempio n. 9
0
def install_plugin(plugin_identifier):
    """Installs a new plugin."""
    validate_plugin(plugin_identifier)
    plugin = get_plugin_from_all(plugin_identifier)
    click.secho("[+] Installing plugin {}...".format(plugin.name), fg="cyan")
    try:
        plugin_manager.install_plugins([plugin])
    except Exception as e:
        click.secho("[-] Couldn't install plugin because of following "
                    "exception: \n{}".format(e), fg="red")
Esempio n. 10
0
def install_plugin(plugin):
    plugin = get_plugin_from_all(plugin)
    if plugin.installable and not plugin.uninstallable:
        plugin.install()
        Setting.invalidate_cache()

        flash(_("Plugin has been installed."), "success")
    else:
        flash(_("Cannot install Plugin."), "danger")

    return redirect(url_for("management.plugins"))
Esempio n. 11
0
def install_plugin(plugin):
    plugin = get_plugin_from_all(plugin)
    if plugin.installable and not plugin.uninstallable:
        plugin.install()
        Setting.invalidate_cache()

        flash(_("Plugin has been installed."), "success")
    else:
        flash(_("Cannot install Plugin."), "danger")

    return redirect(url_for("management.plugins"))
Esempio n. 12
0
    def post(self, plugin):
        plugin = get_plugin_from_all(plugin)
        if not plugin.installed:
            plugin.install()
            Setting.invalidate_cache()

            flash(_("Plugin has been installed."), "success")
        else:
            flash(_("Cannot install plugin."), "danger")

        return redirect(url_for("management.plugins"))
Esempio n. 13
0
def enable_plugin(plugin):
    plugin = get_plugin_from_all(plugin)

    if plugin.enabled:
        flash(_("Plugin is already enabled."), "danger")
        return redirect(url_for("management.plugins"))

    try:
        plugin.enable()
        flash(_("Plugin %(plugin)s enabled. Please restart FlaskBB now.",
                plugin=plugin.name), "success")
    except OSError:
        flash(_("It seems that FlaskBB does not have enough filesystem "
                "permissions. Try removing the 'DISABLED' file by "
                "yourself."), "danger")

    return redirect(url_for("management.plugins"))
Esempio n. 14
0
def enable_plugin(plugin):
    plugin = get_plugin_from_all(plugin)

    if plugin.enabled:
        flash(_("Plugin %(plugin)s is already enabled.", plugin=plugin.name),
              "info")
        return redirect(url_for("management.plugins"))

    try:
        plugin.enable()
        flash(_("Plugin %(plugin)s enabled. Please restart FlaskBB now.",
                plugin=plugin.name), "success")
    except OSError:
        flash(_("It seems that FlaskBB does not have enough filesystem "
                "permissions. Try removing the 'DISABLED' file by "
                "yourself instead."), "danger")

    return redirect(url_for("management.plugins"))
Esempio n. 15
0
def remove_plugin(plugin_identifier, force):
    """Removes a plugin from the filesystem."""
    validate_plugin(plugin_identifier)
    if not force and not \
            click.confirm(click.style("Are you sure?", fg="magenta")):
        sys.exit(0)

    plugin = get_plugin_from_all(plugin_identifier)
    click.secho("[+] Uninstalling plugin {}...".format(plugin.name), fg="cyan")
    try:
        plugin_manager.uninstall_plugins([plugin])
    except Exception as e:
        click.secho("[-] Couldn't uninstall plugin because of following "
                    "exception: \n{}".format(e), fg="red")
        if not click.confirm(click.style(
            "Do you want to continue anyway?", fg="magenta")
        ):
            sys.exit(0)

    click.secho("[+] Removing plugin from filesystem...", fg="cyan")
    shutil.rmtree(plugin.path, ignore_errors=False, onerror=None)
Esempio n. 16
0
def remove_plugin(plugin_identifier, force):
    """Removes a plugin from the filesystem."""
    validate_plugin(plugin_identifier)
    if not force and not \
            click.confirm(click.style("Are you sure?", fg="magenta")):
        sys.exit(0)

    plugin = get_plugin_from_all(plugin_identifier)
    click.secho("[+] Uninstalling plugin {}...".format(plugin.name), fg="cyan")
    try:
        plugin_manager.uninstall_plugins([plugin])
    except Exception as e:
        click.secho("[-] Couldn't uninstall plugin because of following "
                    "exception: \n{}".format(e),
                    fg="red")
        if not click.confirm(
                click.style("Do you want to continue anyway?", fg="magenta")):
            sys.exit(0)

    click.secho("[+] Removing plugin from filesystem...", fg="cyan")
    shutil.rmtree(plugin.path, ignore_errors=False, onerror=None)
Esempio n. 17
0
    def test_get_plugin_from_all(self):
        with self.app.test_request_context():
            plugin = get_plugin_from_all("test3")

        self.assertFalse(plugin.enabled)
Esempio n. 18
0
def index():
    plugin_obj = get_plugin_from_all("plugin_name")
    return render_template("plugin_name.html", plugin_obj=plugin_obj)
Esempio n. 19
0
def enable(plugin):
    plugin = get_plugin_from_all(plugin)
    plugins.enable_plugins([plugin])
    j = {"status": "plugin_action_enabled"}
    return jsonify(j)
Esempio n. 20
0
    def test_get_plugin_from_all(self):
        with self.app.test_request_context():
            plugin = get_plugin_from_all("test3")

        self.assertFalse(plugin.enabled)