Skip to content

Commit

Permalink
Merge pull request #12294 from AUTOMATIC1111/cmd_arg-disable-extensions
Browse files Browse the repository at this point in the history
add cmd_arg --disable-extensions all extra
  • Loading branch information
AUTOMATIC1111 authored Aug 4, 2023
2 parents 09c1be9 + bbfff77 commit 220e298
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions modules/cmd_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,5 @@
parser.add_argument('--add-stop-route', action='store_true', help='add /_stop route to stop server')
parser.add_argument('--api-server-stop', action='store_true', help='enable server stop/restart/kill via api')
parser.add_argument('--timeout-keep-alive', type=int, default=30, help='set timeout_keep_alive for uvicorn')
parser.add_argument("--disable-all-extensions", action='store_true', help="prevent all extensions from running regardless of any other settings", default=False)
parser.add_argument("--disable-extra-extensions", action='store_true', help=" prevent all extensions except built-in from running regardless of any other settings", default=False)
10 changes: 7 additions & 3 deletions modules/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@


def active():
if shared.opts.disable_all_extensions == "all":
if shared.cmd_opts.disable_all_extensions or shared.opts.disable_all_extensions == "all":
return []
elif shared.opts.disable_all_extensions == "extra":
elif shared.cmd_opts.disable_extra_extensions or shared.opts.disable_all_extensions == "extra":
return [x for x in extensions if x.enabled and x.is_builtin]
else:
return [x for x in extensions if x.enabled]
Expand Down Expand Up @@ -141,8 +141,12 @@ def list_extensions():
if not os.path.isdir(extensions_dir):
return

if shared.opts.disable_all_extensions == "all":
if shared.cmd_opts.disable_all_extensions:
print("*** \"--disable-all-extensions\" arg was used, will not load any extensions ***")
elif shared.opts.disable_all_extensions == "all":
print("*** \"Disable all extensions\" option was set, will not load any extensions ***")
elif shared.cmd_opts.disable_extra_extensions:
print("*** \"--disable-extra-extensions\" arg was used, will only load built-in extensions ***")
elif shared.opts.disable_all_extensions == "extra":
print("*** \"Disable all extensions\" option was set, will only load built-in extensions ***")

Expand Down
18 changes: 11 additions & 7 deletions modules/ui_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def extension_table():
ext_status = ext.status

style = ""
if shared.opts.disable_all_extensions == "extra" and not ext.is_builtin or shared.opts.disable_all_extensions == "all":
if shared.cmd_opts.disable_extra_extensions and not ext.is_builtin or shared.opts.disable_all_extensions == "extra" and not ext.is_builtin or shared.cmd_opts.disable_all_extensions or shared.opts.disable_all_extensions == "all":
style = STYLE_PRIMARY

version_link = ext.version
Expand Down Expand Up @@ -537,12 +537,16 @@ def create_ui():
extensions_update_list = gr.Text(elem_id="extensions_update_list", visible=False).style(container=False)

html = ""
if shared.opts.disable_all_extensions != "none":
html = """
<span style="color: var(--primary-400);">
"Disable all extensions" was set, change it to "none" to load all extensions again
</span>
"""

if shared.cmd_opts.disable_all_extensions or shared.cmd_opts.disable_extra_extensions or shared.opts.disable_all_extensions != "none":
if shared.cmd_opts.disable_all_extensions:
msg = '"--disable-all-extensions" was used, remove it to load all extensions again'
elif shared.opts.disable_all_extensions != "none":
msg = '"Disable all extensions" was set, change it to "none" to load all extensions again'
elif shared.cmd_opts.disable_extra_extensions:
msg = '"--disable-extra-extensions" was used, remove it to load all extensions again'
html = f'<span style="color: var(--primary-400);">{msg}</span>'

info = gr.HTML(html)
extensions_table = gr.HTML('Loading...')
ui.load(fn=extension_table, inputs=[], outputs=[extensions_table])
Expand Down

0 comments on commit 220e298

Please sign in to comment.