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
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
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")
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")
def compile_translation(is_all, plugin): """Compiles the translations.""" if plugin is not None: validate_plugin(plugin) click.secho("[+] Compiling language files for plugin {}..." .format(plugin), fg="cyan") compile_plugin_translations(plugin) else: click.secho("[+] Compiling language files...", fg="cyan") compile_translations(include_plugins=is_all)
def update_translation(is_all, plugin): """Updates all translations.""" if plugin is not None: validate_plugin(plugin) click.secho("[+] Updating language files for plugin {}..." .format(plugin), fg="cyan") update_plugin_translations(plugin) else: click.secho("[+] Updating language files...", fg="cyan") update_translations(include_plugins=is_all)
def new_translation(lang, plugin): """Adds a new language to the translations. "lang" is the language code of the language, like, "de_AT".""" if plugin: validate_plugin(plugin) click.secho("[+] Adding new language {} for plugin {}..." .format(lang, plugin), fg="cyan") add_plugin_translations(plugin, lang) else: click.secho("[+] Adding new language {}...".format(lang), fg="cyan") add_translations(lang)
def disable_plugin(plugin_name): """Disables a plugin.""" validate_plugin(plugin_name) plugin = PluginRegistry.query.filter_by(name=plugin_name).first_or_404() if not plugin.enabled: click.secho("Plugin '{}' is already disabled.".format(plugin.name)) plugin.enabled = False plugin.save() click.secho("[+] Plugin '{}' disabled.".format(plugin.name), fg="green")
def uninstall(plugin_name): """Uninstalls a plugin (no migrations).""" validate_plugin(plugin_name) plugin = PluginRegistry.query.filter_by(name=plugin_name).first_or_404() if plugin.is_installed: PluginStore.query.filter_by(plugin_id=plugin.id).delete() db.session.commit() click.secho("[+] Plugin has been uninstalled.", fg="green") else: click.secho("[+] Nothing to uninstall.", fg="green")
def install(plugin_name, force): """Installs a plugin (no migrations).""" validate_plugin(plugin_name) plugin = PluginRegistry.query.filter_by(name=plugin_name).first_or_404() if not plugin.enabled: click.secho("[+] Can't install disabled plugin. " "Enable '{}' Plugin first.".format(plugin.name), fg="red") sys.exit(0) if plugin.is_installable: plugin_module = current_app.pluggy.get_plugin(plugin.name) plugin.add_settings(plugin_module.SETTINGS, force) click.secho("[+] Plugin has been installed.", fg="green") else: click.secho("[+] Nothing to install.", fg="green")
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)
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)