mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-06-07 21:20:49 +00:00
Merge pull request #15470 from AUTOMATIC1111/read-infotext-Script-not-found
error handling paste_field callables
This commit is contained in:
commit
ac8ffb34e3
@ -8,7 +8,7 @@ import sys
|
|||||||
|
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
from modules.paths import data_path
|
from modules.paths import data_path
|
||||||
from modules import shared, ui_tempdir, script_callbacks, processing, infotext_versions, images, prompt_parser
|
from modules import shared, ui_tempdir, script_callbacks, processing, infotext_versions, images, prompt_parser, errors
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
sys.modules['modules.generation_parameters_copypaste'] = sys.modules[__name__] # alias for old name
|
sys.modules['modules.generation_parameters_copypaste'] = sys.modules[__name__] # alias for old name
|
||||||
@ -488,7 +488,11 @@ def connect_paste(button, paste_fields, input_comp, override_settings_component,
|
|||||||
|
|
||||||
for output, key in paste_fields:
|
for output, key in paste_fields:
|
||||||
if callable(key):
|
if callable(key):
|
||||||
v = key(params)
|
try:
|
||||||
|
v = key(params)
|
||||||
|
except Exception:
|
||||||
|
errors.report(f"Error executing {key}", exc_info=True)
|
||||||
|
v = None
|
||||||
else:
|
else:
|
||||||
v = params.get(key, None)
|
v = params.get(key, None)
|
||||||
|
|
||||||
|
@ -739,12 +739,17 @@ class ScriptRunner:
|
|||||||
def onload_script_visibility(params):
|
def onload_script_visibility(params):
|
||||||
title = params.get('Script', None)
|
title = params.get('Script', None)
|
||||||
if title:
|
if title:
|
||||||
title_index = self.titles.index(title)
|
try:
|
||||||
visibility = title_index == self.script_load_ctr
|
title_index = self.titles.index(title)
|
||||||
self.script_load_ctr = (self.script_load_ctr + 1) % len(self.titles)
|
visibility = title_index == self.script_load_ctr
|
||||||
return gr.update(visible=visibility)
|
self.script_load_ctr = (self.script_load_ctr + 1) % len(self.titles)
|
||||||
else:
|
return gr.update(visible=visibility)
|
||||||
return gr.update(visible=False)
|
except ValueError:
|
||||||
|
params['Script'] = None
|
||||||
|
massage = f'Cannot find Script: "{title}"'
|
||||||
|
print(massage)
|
||||||
|
gr.Warning(massage)
|
||||||
|
return gr.update(visible=False)
|
||||||
|
|
||||||
self.infotext_fields.append((dropdown, lambda x: gr.update(value=x.get('Script', 'None'))))
|
self.infotext_fields.append((dropdown, lambda x: gr.update(value=x.get('Script', 'None'))))
|
||||||
self.infotext_fields.extend([(script.group, onload_script_visibility) for script in self.selectable_scripts])
|
self.infotext_fields.extend([(script.group, onload_script_visibility) for script in self.selectable_scripts])
|
||||||
|
Loading…
Reference in New Issue
Block a user