From ec1343c0fae59388a64a22e6289005cb3e7801b2 Mon Sep 17 00:00:00 2001 From: gavin Date: Fri, 28 Feb 2020 15:33:00 +0530 Subject: [PATCH] fix: dont abort script if not overwriting scripts (#919) * fix: dont abort script if not overwriting scripts why: currently, running of `bench ` or `bench setup production` creates nginx conf files and asks for confirmation before overwriting them. in case user doesnt want to overwrite files, `setup production` and `lets-encrypt` is exitted abrubtly and nginx isnt started again after * fix: use click.confirm instead of six.moves.input * fix: use click.confirm instead of six.moves.input * chore: remove unused imports --- bench/config/nginx.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/bench/config/nginx.py b/bench/config/nginx.py index 7e584c3a..9f10c6f7 100644 --- a/bench/config/nginx.py +++ b/bench/config/nginx.py @@ -1,8 +1,24 @@ -import os, json, click, random, string, hashlib -from bench.utils import get_sites, get_bench_name, exec_cmd +# imports - standard imports +import hashlib +import os +import random +import string + +# imports - third party imports +import click from six import string_types +# imports - module imports +from bench.utils import get_bench_name, get_sites + + def make_nginx_conf(bench_path, yes=False): + conf_path = os.path.join(bench_path, "config", "nginx.conf") + + if not yes and os.path.exists(conf_path): + if not click.confirm('nginx.conf already exists and this will overwrite it. Do you want to continue?'): + return + from bench import env from bench.config.common_site_config import get_config @@ -37,10 +53,6 @@ def make_nginx_conf(bench_path, yes=False): nginx_conf = template.render(**template_vars) - conf_path = os.path.join(bench_path, "config", "nginx.conf") - if not yes and os.path.exists(conf_path): - click.confirm('nginx.conf already exists and this will overwrite it. Do you want to continue?', - abort=True) with open(conf_path, "w") as f: f.write(nginx_conf)