-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.py
58 lines (45 loc) · 1.71 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Flask configuration."""
import os
from common_utils import CommonUtils
FLASK_ENV = os.environ.get("FLASK_ENV", "development")
if FLASK_ENV in ["development", "testing"]:
from os import path
from dotenv import load_dotenv
basedir = path.abspath(path.dirname(__file__))
load_dotenv(path.join(basedir, ".env"))
FLASK_ENV = os.environ.get("FLASK_ENV")
TESTING = os.environ.get("TESTING")
DEBUG = os.environ.get("DEBUG")
# Database configuration
DB_NAME = CommonUtils.get_env_sensative_variable("DB_NAME")
DB_USER = CommonUtils.get_env_sensative_variable("DB_USER")
DB_HOST = CommonUtils.get_env_sensative_variable("DB_HOST")
DB_PWD = CommonUtils.get_env_sensative_variable("DB_PASSWORD")
DB_PORT = CommonUtils.get_env_sensative_variable("DB_PORT")
POSTGRES = {
"user": DB_USER,
"password": DB_PWD,
"database": DB_NAME,
"host": DB_HOST,
"port": DB_PORT,
"connection_name": os.environ.get("CONNECTION_NAME"),
}
SQLALCHEMY_DATABASE_URI = (
"postgresql://%(user)s:%(password)s@%(host)s:%(port)s/%(database)s" % POSTGRES
)
# For socket based connection
if FLASK_ENV == "staging":
SQLALCHEMY_DATABASE_URI = (
"postgresql://%(user)s:%(password)s@/%(database)s?host=%(connection_name)s/"
% POSTGRES
)
github_action_db_url = os.environ.get("SQLALCHEMY_DATABASE_URI_GITHUB_ACTION", None)
if github_action_db_url:
SQLALCHEMY_DATABASE_URI = github_action_db_url
WTF_CSRF_ENABLED = True
SECRET_KEY = os.environ.get("SECRET_KEY")
DEFAULT_PROGRAM_ID = 2
DEFAULT_LANGUAGE_ID = 1
DEFAULT_PROGRAM_TIME_CATEGORY = "AFTERNOON"
RETRY_LOGS_BATCH_LIMIT = os.environ.get("RETRY_LOGS_BATCH_LIMIT", 1000)
MAX_RETRY_ATTEMPTS_FOR_LOGS = os.environ.get("MAX_RETRY_ATTEMPTS_FOR_LOGS", 3)