mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-02-01 03:03:00 +08:00
fix to make scripts that failed to compile not crash the program
This commit is contained in:
parent
226de5e503
commit
e67a56dbb4
@ -41,17 +41,21 @@ def load_scripts(basedir):
|
|||||||
with open(path, "r", encoding="utf8") as file:
|
with open(path, "r", encoding="utf8") as file:
|
||||||
text = file.read()
|
text = file.read()
|
||||||
|
|
||||||
from types import ModuleType
|
try:
|
||||||
compiled = compile(text, path, 'exec')
|
from types import ModuleType
|
||||||
module = ModuleType(filename)
|
compiled = compile(text, path, 'exec')
|
||||||
exec(compiled, module.__dict__)
|
module = ModuleType(filename)
|
||||||
|
exec(compiled, module.__dict__)
|
||||||
|
|
||||||
for key, script_class in module.__dict__.items():
|
for key, script_class in module.__dict__.items():
|
||||||
if type(script_class) == type and issubclass(script_class, Script):
|
if type(script_class) == type and issubclass(script_class, Script):
|
||||||
obj = script_class()
|
obj = script_class()
|
||||||
obj.filename = path
|
obj.filename = path
|
||||||
|
|
||||||
scripts.append(obj)
|
scripts.append(obj)
|
||||||
|
except Exception:
|
||||||
|
print(f"Error loading script: {filename}", file=sys.stderr)
|
||||||
|
print(traceback.format_exc(), file=sys.stderr)
|
||||||
|
|
||||||
|
|
||||||
def wrap_call(func, filename, funcname, *args, default=None, **kwargs):
|
def wrap_call(func, filename, funcname, *args, default=None, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user