mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-05-23 19:17:41 +08:00
fix: 修复某些配置无效的问题
common.debug_mode & common.log_length_limit 这gunpg怎么老抽风
This commit is contained in:
parent
bfe23a547f
commit
c0f2f35814
@ -9,10 +9,37 @@
|
||||
# Do not edit except you know what you are doing.
|
||||
|
||||
import os
|
||||
import ujson as json
|
||||
|
||||
def _read_config_file():
|
||||
try:
|
||||
with open("./config.json", "r", encoding = "utf-8") as f:
|
||||
return json.load(f)
|
||||
except:
|
||||
pass
|
||||
|
||||
debug_mode = True
|
||||
log_length_limit = 100000
|
||||
def _read_config(key):
|
||||
try:
|
||||
config = _read_config_file()
|
||||
keys = key.split('.')
|
||||
value = config
|
||||
for k in keys:
|
||||
if isinstance(value, dict):
|
||||
if k not in value and keys.index(k) != len(keys) - 1:
|
||||
value[k] = {}
|
||||
elif k not in value and keys.index(k) == len(keys) - 1:
|
||||
value = None
|
||||
value = value[k]
|
||||
else:
|
||||
value = None
|
||||
break
|
||||
|
||||
return value
|
||||
except:
|
||||
return None
|
||||
|
||||
debug_mode = _read_config("common.debug_mode")
|
||||
log_length_limit = _read_config("common.log_length_limit")
|
||||
running = True
|
||||
config = {}
|
||||
workdir = os.getcwd()
|
||||
|
Loading…
x
Reference in New Issue
Block a user