mirror of
https://github.com/MeoProject/lx-music-api-server.git
synced 2025-05-23 19:17:41 +08:00
feat: 配置文件类型检查
This commit is contained in:
parent
1f380b6dd1
commit
6de45a86e5
@ -16,7 +16,6 @@ import traceback
|
|||||||
import zlib
|
import zlib
|
||||||
import ujson as json
|
import ujson as json
|
||||||
import re
|
import re
|
||||||
import binascii
|
|
||||||
import time
|
import time
|
||||||
import pickle
|
import pickle
|
||||||
from . import log
|
from . import log
|
||||||
|
@ -14,7 +14,6 @@ import os
|
|||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from .utils import readfile
|
|
||||||
from . import variable
|
from . import variable
|
||||||
from .log import log
|
from .log import log
|
||||||
import threading
|
import threading
|
||||||
@ -473,6 +472,12 @@ def initConfig():
|
|||||||
with open("./config.json", "r", encoding="utf-8") as f:
|
with open("./config.json", "r", encoding="utf-8") as f:
|
||||||
try:
|
try:
|
||||||
variable.config = json.loads(f.read())
|
variable.config = json.loads(f.read())
|
||||||
|
if (not isinstance(variable.config, dict)):
|
||||||
|
logger.warning('配置文件并不是一个有效的字典,使用默认值')
|
||||||
|
variable.config = default
|
||||||
|
with open("./config.json", "w", encoding="utf-8") as f:
|
||||||
|
f.write(json.dumps(variable.config, indent=2, ensure_ascii=False))
|
||||||
|
f.close()
|
||||||
except:
|
except:
|
||||||
if os.path.getsize("./config.json") != 0:
|
if os.path.getsize("./config.json") != 0:
|
||||||
logger.error("配置文件加载失败,请检查是否遵循JSON语法规范")
|
logger.error("配置文件加载失败,请检查是否遵循JSON语法规范")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user