fix: global plugin config read

This commit is contained in:
zhayujie
2023-07-20 14:24:40 +08:00
parent 954e55f4b4
commit 4bab4299f2
5 changed files with 38 additions and 29 deletions

View File

@@ -31,12 +31,13 @@ class BDunit(Plugin):
try:
curdir = os.path.dirname(__file__)
config_path = os.path.join(curdir, "config.json")
conf = None
if not os.path.exists(config_path):
raise Exception("config.json not found")
else:
with open(config_path, "r") as f:
conf = super().load_config() or json.load(f)
conf = super().load_config()
if not conf:
if not os.path.exists(config_path):
raise Exception("config.json not found")
else:
with open(config_path, "r") as f:
conf = json.load(f)
self.service_id = conf["service_id"]
self.api_key = conf["api_key"]
self.secret_key = conf["secret_key"]