forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_parse.py
31 lines (26 loc) · 1.15 KB
/
config_parse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import argparse
import os
import pprint
import sys
sys.path.insert(1, os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, "lib")))
from galaxy.config import GalaxyAppConfiguration
from galaxy.util.properties import load_app_properties
def main(config, setting):
# Use explicit config, then env, then guess.
config = config or os.environ.get("GALAXY_CONFIG_FILE", "config/galaxy.yml")
if config and os.path.exists(config):
app_properties = load_app_properties(config_file=config)
gx_config = GalaxyAppConfiguration(**app_properties)
if setting:
print(gx_config.get(setting))
else:
pprint.pprint(gx_config.config_dict)
if __name__ == "__main__":
arg_parser = argparse.ArgumentParser(description="Fetch values from Galaxy config, or print all set values.")
# add optional 'setting' argument
arg_parser.add_argument("-s", "--setting", default=None, help="setting")
arg_parser.add_argument(
"-c", "--config-file", default=None, help="Galaxy config file (defaults to config/galaxy.ini)"
)
args = arg_parser.parse_args()
main(args.config_file, args.setting)