Quellcode durchsuchen

plugins: support reload plugin

master
lanvent vor 1 Jahr
Ursprung
Commit
300b7b9687
3 geänderte Dateien mit 25 neuen und 1 gelöschten Zeilen
  1. +14
    -0
      plugins/godcmd/godcmd.py
  2. +10
    -0
      plugins/plugin_manager.py
  3. +1
    -1
      plugins/sdwebui/sdwebui.py

+ 14
- 0
plugins/godcmd/godcmd.py Datei anzeigen

@@ -63,6 +63,11 @@ ADMIN_COMMANDS = {
"args": ["插件名", "优先级"],
"desc": "设置指定插件的优先级,越大越优先",
},
"reloadp": {
"alias": ["reloadp", "重载插件"],
"args": ["插件名"],
"desc": "重载指定插件配置",
},
"enablep": {
"alias": ["enablep", "启用插件"],
"args": ["插件名"],
@@ -216,6 +221,15 @@ class Godcmd(Plugin):
result = "插件" + args[0] + "优先级已设置为" + args[1]
else:
result = "插件不存在"
elif cmd == "reloadp":
if len(args) != 1:
ok, result = False, "请提供插件名"
else:
ok = PluginManager().reload_plugin(args[0])
if ok:
result = "插件配置已重载"
else:
result = "插件不存在"
elif cmd == "enablep":
if len(args) != 1:
ok, result = False, "请提供插件名"


+ 10
- 0
plugins/plugin_manager.py Datei anzeigen

@@ -96,6 +96,16 @@ class PluginManager:
self.listening_plugins[event].append(name)
self.refresh_order()

def reload_plugin(self, name):
if name in self.instances:
for event in self.listening_plugins:
if name in self.listening_plugins[event]:
self.listening_plugins[event].remove(name)
del self.instances[name]
self.activate_plugins()
return True
return False
def load_plugins(self):
self.load_config()
self.scan_plugins()


+ 1
- 1
plugins/sdwebui/sdwebui.py Datei anzeigen

@@ -78,7 +78,7 @@ class SDWebUI(Plugin):
options = {**self.default_options, **rule_options}
params["prompt"] = params.get("prompt", "")+f", {prompt}"
if len(options) > 0:
logger.info("[SD] cover rule_options={}".format(rule_options))
logger.info("[SD] cover options={}".format(options))
self.api.set_options(options)
logger.info("[SD] params={}".format(params))
result = self.api.txt2img(


Laden…
Abbrechen
Speichern