aboutsummaryrefslogtreecommitdiffstats
path: root/modules/shared.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2022-11-04 06:42:25 +0000
committerAUTOMATIC <16777216c@gmail.com>2022-11-04 06:42:25 +0000
commitf2b69709eaff88fc3a2bd49585556ec0883bf5ea (patch)
treeaf6224830b2d23ac9193d70933e7f69ae169a658 /modules/shared.py
parent26108a7f1c0d269bc67460c04a0852a9eb23f166 (diff)
downloadstable-diffusion-webui-gfx803-f2b69709eaff88fc3a2bd49585556ec0883bf5ea.tar.gz
stable-diffusion-webui-gfx803-f2b69709eaff88fc3a2bd49585556ec0883bf5ea.tar.bz2
stable-diffusion-webui-gfx803-f2b69709eaff88fc3a2bd49585556ec0883bf5ea.zip
move option access checking to options class out of various places scattered through code
Diffstat (limited to 'modules/shared.py')
-rw-r--r--modules/shared.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/shared.py b/modules/shared.py
index d8e99f85..024c771a 100644
--- a/modules/shared.py
+++ b/modules/shared.py
@@ -396,6 +396,15 @@ class Options:
def __setattr__(self, key, value):
if self.data is not None:
if key in self.data or key in self.data_labels:
+ assert not cmd_opts.freeze_settings, "changing settings is disabled"
+
+ comp_args = opts.data_labels[key].component_args
+ if isinstance(comp_args, dict) and comp_args.get('visible', True) is False:
+ raise RuntimeError(f"not possible to set {key} because it is restricted")
+
+ if cmd_opts.hide_ui_dir_config and key in restricted_opts:
+ raise RuntimeError(f"not possible to set {key} because it is restricted")
+
self.data[key] = value
return
@@ -412,6 +421,8 @@ class Options:
return super(Options, self).__getattribute__(item)
def save(self, filename):
+ assert not cmd_opts.freeze_settings, "saving settings is disabled"
+
with open(filename, "w", encoding="utf8") as file:
json.dump(self.data, file, indent=4)