mirror of https://github.com/jumpserver/jumpserver
[Update] 修改config 加载逻辑 (#3528)
parent
bc5a240121
commit
f296dce935
|
@ -442,10 +442,10 @@ class ConfigManager:
|
||||||
try:
|
try:
|
||||||
from config import config as c
|
from config import config as c
|
||||||
self.from_object(c)
|
self.from_object(c)
|
||||||
return self.config
|
return True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass
|
pass
|
||||||
return None
|
return False
|
||||||
|
|
||||||
def load_from_yml(self):
|
def load_from_yml(self):
|
||||||
for i in ['config.yml', 'config.yaml']:
|
for i in ['config.yml', 'config.yaml']:
|
||||||
|
@ -453,7 +453,7 @@ class ConfigManager:
|
||||||
continue
|
continue
|
||||||
loaded = self.from_yaml(i)
|
loaded = self.from_yaml(i)
|
||||||
if loaded:
|
if loaded:
|
||||||
return self.config
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
@ -462,13 +462,13 @@ class ConfigManager:
|
||||||
cls.config_class = config_class
|
cls.config_class = config_class
|
||||||
if not root_path:
|
if not root_path:
|
||||||
root_path = PROJECT_DIR
|
root_path = PROJECT_DIR
|
||||||
|
|
||||||
manager = cls(root_path=root_path)
|
manager = cls(root_path=root_path)
|
||||||
config = manager.load_from_object()
|
if manager.load_from_object():
|
||||||
if config:
|
return manager.config
|
||||||
return config
|
elif manager.load_from_yml():
|
||||||
config = manager.load_from_yml()
|
return manager.config
|
||||||
if config:
|
else:
|
||||||
return config
|
|
||||||
msg = """
|
msg = """
|
||||||
|
|
||||||
Error: No config file found.
|
Error: No config file found.
|
||||||
|
|
Loading…
Reference in New Issue