| 
						
					 | 
					 | 
					@ -18,27 +18,28 @@ def install_plugin_command(ctx, plugin, all):
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    """Install one or more plugins"""
 | 
					 | 
					 | 
					 | 
					    """Install one or more plugins"""
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if not all and len(plugin) == 0:
 | 
					 | 
					 | 
					 | 
					    if not all and len(plugin) == 0:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ctx.fail("At least one plugin must be specified, or use `--all` flag.")
 | 
					 | 
					 | 
					 | 
					        ctx.fail("At least one plugin must be specified, or use `--all` flag.")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if all:
 | 
					 | 
					 | 
					 | 
					    if all:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        plugins = current_app.config["FG_PLUGINS"].values()
 | 
					 | 
					 | 
					 | 
					        plugins = current_app.config["FG_PLUGINS"]
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    else:
 | 
					 | 
					 | 
					 | 
					    else:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        try:
 | 
					 | 
					 | 
					 | 
					        try:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            plugins = [current_app.config["FG_PLUGINS"][p] for p in plugin]
 | 
					 | 
					 | 
					 | 
					            plugins = {plugin_name: current_app.config["FG_PLUGINS"][plugin_name] for plugin_name in plugin}
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        except KeyError as e:
 | 
					 | 
					 | 
					 | 
					        except KeyError as e:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            ctx.fail(f"Invalid plugin ID, could not find >{e.args[0]}<")
 | 
					 | 
					 | 
					 | 
					            ctx.fail(f"Invalid plugin name, could not find >{e.args[0]}<")
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for p in plugins:
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        name = p.id.split(".")[-1]
 | 
					 | 
					 | 
					 | 
					    for name, plugin in plugins.items():
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        click.echo(f"Installing {name}{'.'*(20-len(name))}", nl=False)
 | 
					 | 
					 | 
					 | 
					        click.echo(f"Installing {name}{'.'*(20-len(name))}", nl=False)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        # Install permissions
 | 
					 | 
					 | 
					 | 
					        # Install permissions
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if p.permissions:
 | 
					 | 
					 | 
					 | 
					        if plugin.permissions:
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            cur_perm = set(x.name for x in Permission.query.filter(Permission.name.in_(p.permissions)).all())
 | 
					 | 
					 | 
					 | 
					            cur_perm = set(x.name for x in Permission.query.filter(Permission.name.in_(plugin.permissions)).all())
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            all_perm = set(p.permissions)
 | 
					 | 
					 | 
					 | 
					            all_perm = set(plugin.permissions)
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            add = all_perm - cur_perm
 | 
					 | 
					 | 
					 | 
					            add = all_perm - cur_perm
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            if add:
 | 
					 | 
					 | 
					 | 
					            if add:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                db.session.bulk_save_objects([Permission(name=x) for x in all_perm])
 | 
					 | 
					 | 
					 | 
					                db.session.bulk_save_objects([Permission(name=x) for x in all_perm])
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                db.session.commit()
 | 
					 | 
					 | 
					 | 
					                db.session.commit()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        # Custom installation steps
 | 
					 | 
					 | 
					 | 
					        # Custom installation steps
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        p.install()
 | 
					 | 
					 | 
					 | 
					        plugin.install()
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        click.secho(" ok", fg="green")
 | 
					 | 
					 | 
					 | 
					        click.secho(" ok", fg="green")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
					 | 
					 | 
					@ -61,14 +62,16 @@ def uninstall(ctx: click.Context, plugin):
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if len(plugin) == 0:
 | 
					 | 
					 | 
					 | 
					    if len(plugin) == 0:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ctx.fail("At least one plugin must be specified")
 | 
					 | 
					 | 
					 | 
					        ctx.fail("At least one plugin must be specified")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    try:
 | 
					 | 
					 | 
					 | 
					    try:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        plugins = [current_app.config["FG_PLUGINS"][p] for p in plugin]
 | 
					 | 
					 | 
					 | 
					        plugins = {plugin_name: current_app.config["FG_PLUGINS"][plugin_name] for plugin_name in plugin}
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    except KeyError as e:
 | 
					 | 
					 | 
					 | 
					    except KeyError as e:
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ctx.fail(f"Invalid plugin ID, could not find >{e.args[0]}<")
 | 
					 | 
					 | 
					 | 
					        ctx.fail(f"Invalid plugin ID, could not find >{e.args[0]}<")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if (
 | 
					 | 
					 | 
					 | 
					    if (
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        click.prompt(
 | 
					 | 
					 | 
					 | 
					        click.prompt(
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            "You are going to uninstall:\n\n"
 | 
					 | 
					 | 
					 | 
					            "You are going to uninstall:\n\n"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            f"\t{', '.join([p.id.split('.')[-1] for p in plugins])}\n\n"
 | 
					 | 
					 | 
					 | 
					            f"\t{', '.join([plugin_name for plugin_name in plugins.keys()])}\n\n"
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            "Are you sure?",
 | 
					 | 
					 | 
					 | 
					            "Are you sure?",
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            default="n",
 | 
					 | 
					 | 
					 | 
					            default="n",
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            show_choices=True,
 | 
					 | 
					 | 
					 | 
					            show_choices=True,
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
					 | 
					 | 
					@ -77,10 +80,9 @@ def uninstall(ctx: click.Context, plugin):
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        != "y"
 | 
					 | 
					 | 
					 | 
					        != "y"
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ):
 | 
					 | 
					 | 
					 | 
					    ):
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ctx.exit()
 | 
					 | 
					 | 
					 | 
					        ctx.exit()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    for p in plugins:
 | 
					 | 
					 | 
					 | 
					    for name, plugin in plugins.items():
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        name = p.id.split(".")[-1]
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        click.echo(f"Uninstalling {name}{'.'*(20-len(name))}", nl=False)
 | 
					 | 
					 | 
					 | 
					        click.echo(f"Uninstalling {name}{'.'*(20-len(name))}", nl=False)
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        p.uninstall()
 | 
					 | 
					 | 
					 | 
					        plugin.uninstall()
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        click.secho(" ok", fg="green")
 | 
					 | 
					 | 
					 | 
					        click.secho(" ok", fg="green")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
					 | 
					 | 
					@ -95,7 +97,7 @@ def ls(enabled, no_header):
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return p.version
 | 
					 | 
					 | 
					 | 
					        return p.version
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    plugins = entry_points(group="flaschengeist.plugins")
 | 
					 | 
					 | 
					 | 
					    plugins = entry_points(group="flaschengeist.plugins")
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    enabled_plugins = [key for key, value in config.items() if "enabled" in value] + [config["FLASCHENGEIST"]["auth"]]
 | 
					 | 
					 | 
					 | 
					    enabled_plugins = [key for key, value in config.items() if "enabled" in value and value["enabled"]] + [config["FLASCHENGEIST"]["auth"]]
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    loaded_plugins = current_app.config["FG_PLUGINS"].keys()
 | 
					 | 
					 | 
					 | 
					    loaded_plugins = current_app.config["FG_PLUGINS"].keys()
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if not no_header:
 | 
					 | 
					 | 
					 | 
					    if not no_header:
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
					 | 
					 | 
					
 
 |