This repository has been archived by the owner on Jul 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
73 lines (51 loc) · 2.29 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""Intranet de la Rez Flask App - Configuration"""
import os
from dotenv import load_dotenv
basedir = os.path.abspath(os.path.dirname(__file__))
load_dotenv(os.path.join(basedir, ".env"))
def get_or_die(name: str) -> str:
"""Check availability and get the value of an environment variable.
Args:
name (str): The environment variable to get.
Returns:
The environment variable value, if it is set.
Raises:
RuntimeError: if the environment variable is not set.
"""
var = os.environ.get(name)
if var is None:
raise RuntimeError(f"Missing environment variable '{name}'")
return var
class Config():
"""IntraRez Flask Web App Configuration."""
SECRET_KEY = os.environ.get("SECRET_KEY")
LANGUAGES = ["fr", "en"]
PREFERRED_URL_SCHEME = os.environ.get("PREFERRED_URL_SCHEME")
SERVER_NAME = os.environ.get("SERVER_NAME")
APPLICATION_ROOT = os.environ.get("APPLICATION_ROOT")
SQLALCHEMY_DATABASE_URI = get_or_die("SQLALCHEMY_DATABASE_URI")
SQLALCHEMY_TRACK_MODIFICATIONS = False
MAIL_SERVER = os.environ.get("MAIL_SERVER")
MAIL_PORT = int(os.environ.get("MAIL_PORT") or 25)
MAIL_USE_TLS = os.environ.get("MAIL_USE_TLS") is not None
MAIL_USERNAME = os.environ.get("MAIL_USERNAME")
MAIL_PASSWORD = os.environ.get("MAIL_PASSWORD")
ADMINS = os.environ.get("ADMINS", "").split(";")
ERROR_WEBHOOK = os.environ.get("ERROR_WEBHOOK")
LOGGING_WEBHOOK = os.environ.get("LOGGING_WEBHOOK")
MESSAGE_WEBHOOK = os.environ.get("MESSAGE_WEBHOOK")
MAIL_WEBHOOK = os.environ.get("MAIL_WEBHOOK")
GRI_ROLE_ID = os.environ.get("GRI_ROLE_ID")
LYDIA_BASE_URL = os.environ.get("LYDIA_BASE_URL")
LYDIA_VENDOR_TOKEN = os.environ.get("LYDIA_VENDOR_TOKEN")
LYDIA_PRIVATE_TOKEN = os.environ.get("LYDIA_PRIVATE_TOKEN")
GOOGLE_RECAPTCHA_SITEKEY = os.environ.get("GOOGLE_RECAPTCHA_SITEKEY")
GOOGLE_RECAPTCHA_SECRET = os.environ.get("GOOGLE_RECAPTCHA_SECRET")
GRI_BASIC_PASSWORD = os.environ.get("GRI_BASIC_PASSWORD")
BRANCH = os.environ.get("BRANCH")
FORCE_IP = os.environ.get("FORCE_IP")
FORCE_MAC = os.environ.get("FORCE_MAC")
NETLOCS = os.environ.get("NETLOCS")
if NETLOCS is not None:
NETLOCS = NETLOCS.split(";")
MAINTENANCE = bool(os.environ.get("MAINTENANCE"))