Don't override net config if env variables don't exist

This commit is contained in:
cmdr2 2023-04-27 15:58:06 +05:30
parent e01d68fce3
commit 400cb218ba

View File

@ -81,12 +81,8 @@ def getConfig(default_val=APP_CONFIG_DEFAULTS):
config["net"] = {} config["net"] = {}
if os.getenv("SD_UI_BIND_PORT") is not None: if os.getenv("SD_UI_BIND_PORT") is not None:
config["net"]["listen_port"] = int(os.getenv("SD_UI_BIND_PORT")) config["net"]["listen_port"] = int(os.getenv("SD_UI_BIND_PORT"))
else:
config["net"]["listen_port"] = 9000
if os.getenv("SD_UI_BIND_IP") is not None: if os.getenv("SD_UI_BIND_IP") is not None:
config["net"]["listen_to_network"] = os.getenv("SD_UI_BIND_IP") == "0.0.0.0" config["net"]["listen_to_network"] = os.getenv("SD_UI_BIND_IP") == "0.0.0.0"
else:
config["net"]["listen_to_network"] = True
return config return config
except Exception as e: except Exception as e:
log.warn(traceback.format_exc()) log.warn(traceback.format_exc())
@ -188,7 +184,7 @@ def getIPConfig():
def open_browser(): def open_browser():
config = getConfig() config = getConfig()
ui = config.get("ui", {}) ui = config.get("ui", {})
net = config.get("net", {"listen_port": 9000}) net = config.get("net", {})
port = net.get("listen_port", 9000) port = net.get("listen_port", 9000)
if ui.get("open_browser_on_start", True): if ui.get("open_browser_on_start", True):
import webbrowser import webbrowser