mirror of
https://github.com/frappe/bench.git
synced 2024-11-12 00:06:36 +00:00
refactor: bench.commands.config
* sorted imports * made it a little DRY * code formatting * added help
This commit is contained in:
parent
e4355001e7
commit
53e2272a66
@ -17,50 +17,43 @@ def config():
|
|||||||
@click.command('auto_update', help='Enable/Disable auto update for bench')
|
@click.command('auto_update', help='Enable/Disable auto update for bench')
|
||||||
@click.argument('state', type=click.Choice(['on', 'off']))
|
@click.argument('state', type=click.Choice(['on', 'off']))
|
||||||
def config_auto_update(state):
|
def config_auto_update(state):
|
||||||
state = True if state == 'on' else False
|
update_config({'auto_update': state == 'on'})
|
||||||
update_config({'auto_update': state})
|
|
||||||
|
|
||||||
|
|
||||||
@click.command('restart_supervisor_on_update', help='Enable/Disable auto restart of supervisor processes')
|
@click.command('restart_supervisor_on_update', help='Enable/Disable auto restart of supervisor processes')
|
||||||
@click.argument('state', type=click.Choice(['on', 'off']))
|
@click.argument('state', type=click.Choice(['on', 'off']))
|
||||||
def config_restart_supervisor_on_update(state):
|
def config_restart_supervisor_on_update(state):
|
||||||
state = True if state == 'on' else False
|
update_config({'restart_supervisor_on_update': state == 'on'})
|
||||||
update_config({'restart_supervisor_on_update': state})
|
|
||||||
|
|
||||||
|
|
||||||
@click.command('restart_systemd_on_update', help='Enable/Disable auto restart of systemd units')
|
@click.command('restart_systemd_on_update', help='Enable/Disable auto restart of systemd units')
|
||||||
@click.argument('state', type=click.Choice(['on', 'off']))
|
@click.argument('state', type=click.Choice(['on', 'off']))
|
||||||
def config_restart_systemd_on_update(state):
|
def config_restart_systemd_on_update(state):
|
||||||
state = True if state == 'on' else False
|
update_config({'restart_systemd_on_update': state == 'on'})
|
||||||
update_config({'restart_systemd_on_update': state})
|
|
||||||
|
|
||||||
|
|
||||||
@click.command('update_bench_on_update', help='Enable/Disable bench updates on running bench update')
|
@click.command('update_bench_on_update', help='Enable/Disable bench updates on running bench update')
|
||||||
@click.argument('state', type=click.Choice(['on', 'off']))
|
@click.argument('state', type=click.Choice(['on', 'off']))
|
||||||
def config_update_bench_on_update(state):
|
def config_update_bench_on_update(state):
|
||||||
state = True if state == 'on' else False
|
update_config({'update_bench_on_update': state == 'on'})
|
||||||
update_config({'update_bench_on_update': state})
|
|
||||||
|
|
||||||
|
|
||||||
@click.command('dns_multitenant', help='Enable/Disable bench multitenancy on running bench update')
|
@click.command('dns_multitenant', help='Enable/Disable bench multitenancy on running bench update')
|
||||||
@click.argument('state', type=click.Choice(['on', 'off']))
|
@click.argument('state', type=click.Choice(['on', 'off']))
|
||||||
def config_dns_multitenant(state):
|
def config_dns_multitenant(state):
|
||||||
state = True if state == 'on' else False
|
update_config({'dns_multitenant': state == 'on'})
|
||||||
update_config({'dns_multitenant': state})
|
|
||||||
|
|
||||||
|
|
||||||
@click.command('serve_default_site', help='Configure nginx to serve the default site on port 80')
|
@click.command('serve_default_site', help='Configure nginx to serve the default site on port 80')
|
||||||
@click.argument('state', type=click.Choice(['on', 'off']))
|
@click.argument('state', type=click.Choice(['on', 'off']))
|
||||||
def config_serve_default_site(state):
|
def config_serve_default_site(state):
|
||||||
state = True if state == 'on' else False
|
update_config({'serve_default_site': state == 'on'})
|
||||||
update_config({'serve_default_site': state})
|
|
||||||
|
|
||||||
|
|
||||||
@click.command('rebase_on_pull', help='Rebase repositories on pulling')
|
@click.command('rebase_on_pull', help='Rebase repositories on pulling')
|
||||||
@click.argument('state', type=click.Choice(['on', 'off']))
|
@click.argument('state', type=click.Choice(['on', 'off']))
|
||||||
def config_rebase_on_pull(state):
|
def config_rebase_on_pull(state):
|
||||||
state = True if state == 'on' else False
|
update_config({'rebase_on_pull': state == 'on'})
|
||||||
update_config({'rebase_on_pull': state})
|
|
||||||
|
|
||||||
|
|
||||||
@click.command('http_timeout', help='Set HTTP timeout')
|
@click.command('http_timeout', help='Set HTTP timeout')
|
||||||
@ -74,24 +67,10 @@ def config_http_timeout(seconds):
|
|||||||
def set_common_config(configs):
|
def set_common_config(configs):
|
||||||
common_site_config = {}
|
common_site_config = {}
|
||||||
for key, value in configs:
|
for key, value in configs:
|
||||||
if value in ("False", "True"):
|
if value in ('true', 'false'):
|
||||||
|
value = value.title()
|
||||||
|
try:
|
||||||
value = ast.literal_eval(value)
|
value = ast.literal_eval(value)
|
||||||
|
|
||||||
elif "." in value:
|
|
||||||
try:
|
|
||||||
value = float(value)
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
elif "{" in value or "[" in value:
|
|
||||||
try:
|
|
||||||
value = json.loads(value)
|
|
||||||
except ValueError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
value = int(value)
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user