Set POSTGRES_USER and POSTGRES_PASSWORD to the debug value when opting for debug

This commit is contained in:
Nikita P. Shupeyko 2018-05-05 13:47:58 +03:00
parent a22390ad4f
commit 1732659678

View File

@ -28,6 +28,8 @@ INFO = "\x1b[1;33m [INFO]: "
HINT = "\x1b[3;33m"
SUCCESS = "\x1b[1;32m [SUCCESS]: "
DEBUG_VALUE = "debug"
def remove_open_source_files():
file_names = ["CONTRIBUTORS.txt"]
@ -166,21 +168,24 @@ def set_django_admin_url(file_path):
return django_admin_url
def generate_postgres_user():
return generate_random_string(length=32, using_ascii_letters=True)
def generate_postgres_user(debug=False):
return DEBUG_VALUE if debug else generate_random_string(length=32, using_ascii_letters=True)
def set_postgres_user(file_path, value=None):
def set_postgres_user(file_path, value):
postgres_user = set_flag(
file_path, "!!!SET POSTGRES_USER!!!", value=value or generate_postgres_user()
file_path,
"!!!SET POSTGRES_USER!!!",
value=value,
)
return postgres_user
def set_postgres_password(file_path):
def set_postgres_password(file_path, value=None):
postgres_password = set_flag(
file_path,
"!!!SET POSTGRES_PASSWORD!!!",
value=value,
length=64,
using_digits=True,
using_ascii_letters=True,
@ -194,10 +199,10 @@ def append_to_gitignore_file(s):
gitignore_file.write(os.linesep)
def set_flags_in_envs(postgres_user):
def set_flags_in_envs(postgres_user, debug=False):
local_postgres_envs_path = os.path.join(".envs", ".local", ".postgres")
set_postgres_user(local_postgres_envs_path, value=postgres_user)
set_postgres_password(local_postgres_envs_path)
set_postgres_password(local_postgres_envs_path, value=DEBUG_VALUE if debug else None)
production_django_envs_path = os.path.join(".envs", ".production", ".django")
set_django_secret_key(production_django_envs_path)
@ -205,7 +210,7 @@ def set_flags_in_envs(postgres_user):
production_postgres_envs_path = os.path.join(".envs", ".production", ".postgres")
set_postgres_user(production_postgres_envs_path, value=postgres_user)
set_postgres_password(production_postgres_envs_path)
set_postgres_password(production_postgres_envs_path, value=DEBUG_VALUE if debug else None)
def set_flags_in_settings_files():
@ -224,8 +229,8 @@ def remove_celery_compose_dirs():
def main():
postgres_user = generate_postgres_user()
set_flags_in_envs(postgres_user)
postgres_user = generate_postgres_user(debug="{{ cookiecutter.debug }}".lower() == "y")
set_flags_in_envs(postgres_user, debug="{{ cookiecutter.debug }}".lower() == "y")
set_flags_in_settings_files()
if "{{ cookiecutter.open_source_license }}" == "Not open source":