mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-07 11:59:18 +00:00
[Update] 修改配置文件加载
This commit is contained in:
parent
d664018bd7
commit
d8069f47f2
@ -193,8 +193,8 @@ class Config(dict):
|
|||||||
if self.root_path:
|
if self.root_path:
|
||||||
filename = os.path.join(self.root_path, filename)
|
filename = os.path.join(self.root_path, filename)
|
||||||
try:
|
try:
|
||||||
with open(filename) as json_file:
|
with open(filename) as f:
|
||||||
obj = yaml.load(json_file)
|
obj = yaml.load(f)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
if silent and e.errno in (errno.ENOENT, errno.EISDIR):
|
if silent and e.errno in (errno.ENOENT, errno.EISDIR):
|
||||||
return False
|
return False
|
||||||
@ -202,8 +202,7 @@ class Config(dict):
|
|||||||
raise
|
raise
|
||||||
if obj:
|
if obj:
|
||||||
return self.from_mapping(obj)
|
return self.from_mapping(obj)
|
||||||
else:
|
return True
|
||||||
return False
|
|
||||||
|
|
||||||
def from_mapping(self, *mapping, **kwargs):
|
def from_mapping(self, *mapping, **kwargs):
|
||||||
"""Updates the config like :meth:`update` ignoring items with non-upper
|
"""Updates the config like :meth:`update` ignoring items with non-upper
|
||||||
|
2
jms
2
jms
@ -18,7 +18,7 @@ try:
|
|||||||
from apps.jumpserver.conf import load_user_config
|
from apps.jumpserver.conf import load_user_config
|
||||||
CONFIG = load_user_config()
|
CONFIG = load_user_config()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("Could not find config file, `cp config_example.py config.py`")
|
print("Could not find config file, `cp config_example.yml config.yml`")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
os.environ["PYTHONIOENCODING"] = "UTF-8"
|
os.environ["PYTHONIOENCODING"] = "UTF-8"
|
||||||
|
Loading…
Reference in New Issue
Block a user