Skip to content

Commit

Permalink
fix: dont abort script if not overwriting scripts (frappe#919)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gavindsouza committed Feb 28, 2020
1 parent ddcd2c1 commit ec1343c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions 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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ec1343c

Please sign in to comment.