Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
f296dce9
Unverified
Commit
f296dce9
authored
5 years ago
by
BaiJiangJie
Committed by
GitHub
5 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改config 加载逻辑 (#3528)
parent
bc5a2401
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
conf.py
apps/jumpserver/conf.py
+16
-16
No files found.
apps/jumpserver/conf.py
View file @
f296dce9
...
@@ -442,10 +442,10 @@ class ConfigManager:
...
@@ -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
Non
e
return
Fals
e
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:
...
@@ -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,20 +462,20 @@ class ConfigManager:
...
@@ -462,20 +462,20 @@ 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
)
config
=
manager
.
load_from_object
()
if
config
:
return
config
config
=
manager
.
load_from_yml
()
if
config
:
return
config
msg
=
"""
Error: No config file found.
manager
=
cls
(
root_path
=
root_path
)
if
manager
.
load_from_object
():
You can run `cp config_example.yml config.yml`, and edit it.
return
manager
.
config
"""
elif
manager
.
load_from_yml
():
raise
ImportError
(
msg
)
return
manager
.
config
else
:
msg
=
"""
Error: No config file found.
You can run `cp config_example.yml config.yml`, and edit it.
"""
raise
ImportError
(
msg
)
@classmethod
@classmethod
def
get_dynamic_config
(
cls
,
config
):
def
get_dynamic_config
(
cls
,
config
):
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment