Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F24895470
salt-get-config-dir.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
salt-get-config-dir.py
View Options
#!/usr/bin/env python3
# -------------------------------------------------------------
# salt-get-config-dir command
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Project: salt-wrapper
# Licence: BSD-2-Clause
# -------------------------------------------------------------
import
json
import
os
import
sys
# -------------------------------------------------------------
# Load configuration
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
config_file_path
=
os
.
environ
.
get
(
"SALT_WRAPPER_CONF"
,
"/usr/local/etc/salt-wrapper.conf"
)
if
not
os
.
path
.
isfile
(
config_file_path
):
print
(
"The configuration file {0} doesn't exist."
.
format
(
config_file_path
),
file
=
sys
.
stderr
)
print
(
"See https://docs.nasqueron.org/salt-wrapper/admin.html#configuration-file"
,
# noqa
file
=
sys
.
stderr
)
sys
.
exit
(
2
)
try
:
with
open
(
config_file_path
)
as
config_file
:
config
=
json
.
load
(
config_file
)
except
OSError
as
err
:
print
(
"Can't open configuration file: {0}"
.
format
(
err
))
sys
.
exit
(
4
)
# -------------------------------------------------------------
# Find configuration directory
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
for
root
in
config
[
'roots'
]:
if
os
.
getcwd
()
.
startswith
(
root
[
'states'
]):
print
(
root
[
'config'
])
sys
.
exit
(
0
)
sys
.
exit
(
1
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Wed, Mar 18, 14:18 (8 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3466932
Default Alt Text
salt-get-config-dir.py (1 KB)
Attached To
Mode
rSW salt-wrapper
Attached
Detach File
Event Timeline
Log In to Comment