from argh import arg
import gws
import gws.config
import gws.config.loader
import gws.tools.clihelpers
import gws.tools.json2
import gws.gis.mpx.config
COMMAND = 'config'
[docs]@arg('--path', help='configuration file path')
def test(path=None):
"""Run a configuration file test"""
root = gws.config.loader.parse_and_activate(path)
if root.var('server.mapproxy.enabled'):
gws.gis.mpx.config.create_and_save(root, '/tmp/mapproxy-check')
gws.log.info('CONFIGURATION OK')
[docs]@arg('--path', help='configuration file path')
def prepare(path=None):
"""Parse and prepare a config"""
root = gws.config.loader.parse_and_activate(path)
gws.config.loader.store(root)
[docs]@arg('--path', help='configuration file path')
@arg('--out', help='path to write the dump to')
def dump(path=None, out=None):
"""Dump the configuarion tree"""
if path:
root = gws.config.loader.parse_and_activate(path)
else:
root = gws.config.loader.load()
r = gws.tools.json2.to_tagged_string(root, pretty=True, ascii=False)
if not out:
print(r)
return
with open(out, 'wt') as fp:
fp.write(r)