Skip to content

Commit 42446a7

Browse files
Merge pull request cuttlesystems#287 from cuttlesystems/deploy_server_python/main
'SECRET_KEY' argument added
2 parents 6ee6d31 + 9373c0d commit 42446a7

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

deploy/deploy_server/scripts/deploy_server_utils.py

+21-3
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@ class PostgresEnvVariables:
4545
DB_PORT: str
4646
DOMAIN_HOST: str
4747
HOST_PROTOCOL: str
48+
SECRET_KEY: str
4849
# 'DB_ENGINE=django.db.backends.postgresql
4950
# DB_NAME=bot_constructor
5051
# POSTGRES_USER=postgres
5152
# POSTGRES_PASSWORD=zarFad-huqdit-qavry0
5253
# DB_HOST=172.21.0.1
5354
# DB_PORT=5432
5455
# DOMAIN_HOST=ramasuchka.kz
55-
# HOST_PROTOCOL=https'
56+
# HOST_PROTOCOL=https
57+
# SECRET_KEY='
5658

5759

5860
def get_script_dir_path() -> Path:
@@ -857,6 +859,9 @@ def write_postgres_env_variables_json() -> None:
857859
),
858860
HOST_PROTOCOL=input(
859861
'Enter \'HOST_PROTOCOL\' value (push \'Enter\' for default - \"https\"): '
862+
),
863+
SECRET_KEY=input(
864+
'Enter \'SECRET_KEY\' value (has no default value, should be entered!): '
860865
)
861866
)
862867
if postgres_env_variables.DB_ENGINE == '':
@@ -875,6 +880,14 @@ def write_postgres_env_variables_json() -> None:
875880
postgres_env_variables.DOMAIN_HOST = 'ramasuchka.kz'
876881
if postgres_env_variables.HOST_PROTOCOL == '':
877882
postgres_env_variables.HOST_PROTOCOL = 'https'
883+
if postgres_env_variables.SECRET_KEY == '':
884+
print(
885+
f'Значение аргумента \'SECRET_KEY\' не было задано - '
886+
f'функционирование базы данных в данном случае невозможно'
887+
f'Скрипт остановлен'
888+
f'Для осуществления разворота выполните перезапуск скрипта'
889+
)
890+
exit(0)
878891
assert isinstance(postgres_env_variables, PostgresEnvVariables)
879892
params = {
880893
'DB_ENGINE': postgres_env_variables.DB_ENGINE,
@@ -884,7 +897,8 @@ def write_postgres_env_variables_json() -> None:
884897
'DB_HOST': postgres_env_variables.DB_HOST,
885898
'DB_PORT': postgres_env_variables.DB_PORT,
886899
'DOMAIN_HOST': postgres_env_variables.DOMAIN_HOST,
887-
'HOST_PROTOCOL': postgres_env_variables.HOST_PROTOCOL
900+
'HOST_PROTOCOL': postgres_env_variables.HOST_PROTOCOL,
901+
'SECRET_KEY': postgres_env_variables.SECRET_KEY
888902
}
889903
with open(f'{get_postgres_env_file_path()}_json', 'wt', encoding='utf-8') as envfile:
890904
json.dump(params, envfile)
@@ -917,6 +931,7 @@ def convert_postgres_env_variables_json_to_text() -> None:
917931
envfile.writelines(f'DB_PORT={postgres_env_variables.DB_PORT}\n')
918932
envfile.writelines(f'DOMAIN_HOST={postgres_env_variables.DOMAIN_HOST}\n')
919933
envfile.writelines(f'HOST_PROTOCOL={postgres_env_variables.HOST_PROTOCOL}')
934+
envfile.writelines(f'SECRET_KEY={postgres_env_variables.SECRET_KEY}')
920935
print(
921936
f'\n---------------------------------------------------------\n'
922937
f'postgres environment variables were written into file'
@@ -930,6 +945,7 @@ def convert_postgres_env_variables_json_to_text() -> None:
930945
f'DB_PORT={postgres_env_variables.DB_PORT}\n'
931946
f'DOMAIN_HOST={postgres_env_variables.DOMAIN_HOST}\n'
932947
f'HOST_PROTOCOL={postgres_env_variables.HOST_PROTOCOL}\n'
948+
f'SECRET_KEY={postgres_env_variables.SECRET_KEY}\n'
933949
f'\n---------------------------------------------------------\n'
934950
)
935951

@@ -955,7 +971,8 @@ def read_postgres_env_variables_json() -> PostgresEnvVariables:
955971
DB_HOST=postgres_env_variables['DB_HOST'],
956972
DB_PORT=postgres_env_variables['DB_PORT'],
957973
DOMAIN_HOST=postgres_env_variables['DOMAIN_HOST'],
958-
HOST_PROTOCOL=postgres_env_variables['HOST_PROTOCOL']
974+
HOST_PROTOCOL=postgres_env_variables['HOST_PROTOCOL'],
975+
SECRET_KEY=postgres_env_variables['SECRET_KEY']
959976
)
960977

961978
return postgres_env_variables
@@ -1000,6 +1017,7 @@ def get_postgres_env_variables() -> PostgresEnvVariables:
10001017
print(f'DB_PORT: {postgres_env_variables.DB_PORT}')
10011018
print(f'DOMAIN_HOST: {postgres_env_variables.DOMAIN_HOST}')
10021019
print(f'HOST_PROTOCOL: {postgres_env_variables.HOST_PROTOCOL}')
1020+
print(f'SECRET_KEY: {postgres_env_variables.SECRET_KEY}')
10031021
return postgres_env_variables
10041022

10051023

0 commit comments

Comments
 (0)