correct indent
This commit is contained in:
parent
2deea86781
commit
e808096cf6
2 changed files with 36 additions and 35 deletions
|
@ -163,37 +163,39 @@ class ScriptRunner:
|
||||||
return processed
|
return processed
|
||||||
|
|
||||||
def reload_sources(self):
|
def reload_sources(self):
|
||||||
for si,script in list(enumerate(self.scripts)):
|
for si, script in list(enumerate(self.scripts)):
|
||||||
with open(script.filename, "r", encoding="utf8") as file:
|
with open(script.filename, "r", encoding="utf8") as file:
|
||||||
args_from = script.args_from
|
args_from = script.args_from
|
||||||
args_to = script.args_to
|
args_to = script.args_to
|
||||||
filename = script.filename
|
filename = script.filename
|
||||||
text = file.read()
|
text = file.read()
|
||||||
|
|
||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
compiled = compile(text, filename, 'exec')
|
|
||||||
module = ModuleType(script.filename)
|
|
||||||
exec(compiled, module.__dict__)
|
|
||||||
|
|
||||||
for key, script_class in module.__dict__.items():
|
compiled = compile(text, filename, 'exec')
|
||||||
if type(script_class) == type and issubclass(script_class, Script):
|
module = ModuleType(script.filename)
|
||||||
self.scripts[si] = script_class()
|
exec(compiled, module.__dict__)
|
||||||
self.scripts[si].filename = filename
|
|
||||||
self.scripts[si].args_from = args_from
|
for key, script_class in module.__dict__.items():
|
||||||
self.scripts[si].args_to = args_to
|
if type(script_class) == type and issubclass(script_class, Script):
|
||||||
|
self.scripts[si] = script_class()
|
||||||
|
self.scripts[si].filename = filename
|
||||||
|
self.scripts[si].args_from = args_from
|
||||||
|
self.scripts[si].args_to = args_to
|
||||||
|
|
||||||
scripts_txt2img = ScriptRunner()
|
scripts_txt2img = ScriptRunner()
|
||||||
scripts_img2img = ScriptRunner()
|
scripts_img2img = ScriptRunner()
|
||||||
|
|
||||||
def reload_script_body_only():
|
def reload_script_body_only():
|
||||||
scripts_txt2img.reload_sources()
|
scripts_txt2img.reload_sources()
|
||||||
scripts_img2img.reload_sources()
|
scripts_img2img.reload_sources()
|
||||||
|
|
||||||
|
|
||||||
def reload_scripts(basedir):
|
def reload_scripts(basedir):
|
||||||
global scripts_txt2img,scripts_img2img
|
global scripts_txt2img, scripts_img2img
|
||||||
|
|
||||||
scripts_data.clear()
|
scripts_data.clear()
|
||||||
load_scripts(basedir)
|
load_scripts(basedir)
|
||||||
|
|
||||||
scripts_txt2img = ScriptRunner()
|
scripts_txt2img = ScriptRunner()
|
||||||
scripts_img2img = ScriptRunner()
|
scripts_img2img = ScriptRunner()
|
||||||
|
|
|
@ -1003,12 +1003,12 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
|
||||||
)
|
)
|
||||||
|
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
reload_script_bodies = gr.Button(value='Reload custom script bodies (No ui updates, No restart)', variant='secondary')
|
reload_script_bodies = gr.Button(value='Reload custom script bodies (No ui updates, No restart)', variant='secondary')
|
||||||
restart_gradio = gr.Button(value='Restart Gradio and Refresh components (Custom Scripts, ui.py, js and css only)', variant='primary')
|
restart_gradio = gr.Button(value='Restart Gradio and Refresh components (Custom Scripts, ui.py, js and css only)', variant='primary')
|
||||||
|
|
||||||
|
|
||||||
def reload_scripts():
|
def reload_scripts():
|
||||||
modules.scripts.reload_script_body_only()
|
modules.scripts.reload_script_body_only()
|
||||||
|
|
||||||
reload_script_bodies.click(
|
reload_script_bodies.click(
|
||||||
fn=reload_scripts,
|
fn=reload_scripts,
|
||||||
|
@ -1018,7 +1018,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
|
||||||
)
|
)
|
||||||
|
|
||||||
def request_restart():
|
def request_restart():
|
||||||
settings_interface.gradio_ref.do_restart = True
|
settings_interface.gradio_ref.do_restart = True
|
||||||
|
|
||||||
restart_gradio.click(
|
restart_gradio.click(
|
||||||
fn=request_restart,
|
fn=request_restart,
|
||||||
|
@ -1234,12 +1234,11 @@ for filename in sorted(os.listdir(jsdir)):
|
||||||
|
|
||||||
|
|
||||||
if 'gradio_routes_templates_response' not in globals():
|
if 'gradio_routes_templates_response' not in globals():
|
||||||
def template_response(*args, **kwargs):
|
def template_response(*args, **kwargs):
|
||||||
res = gradio_routes_templates_response(*args, **kwargs)
|
res = gradio_routes_templates_response(*args, **kwargs)
|
||||||
res.body = res.body.replace(b'</head>', f'{javascript}</head>'.encode("utf8"))
|
res.body = res.body.replace(b'</head>', f'{javascript}</head>'.encode("utf8"))
|
||||||
res.init_headers()
|
res.init_headers()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
gradio_routes_templates_response = gradio.routes.templates.TemplateResponse
|
|
||||||
gradio.routes.templates.TemplateResponse = template_response
|
|
||||||
|
|
||||||
|
gradio_routes_templates_response = gradio.routes.templates.TemplateResponse
|
||||||
|
gradio.routes.templates.TemplateResponse = template_response
|
||||||
|
|
Loading…
Reference in a new issue