forked from DGNum/gestioCOF
More verbose secret error reporting
This commit is contained in:
parent
e13d68a127
commit
88597e62f1
2 changed files with 42 additions and 20 deletions
|
@ -8,26 +8,42 @@ the local development server should be here.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# Database credentials
|
|
||||||
try:
|
try:
|
||||||
from .secret import DBNAME, DBUSER, DBPASSWD
|
from . import secret
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# On the local development VM, theses credentials are in the environment
|
raise ImportError(
|
||||||
DBNAME = os.environ["DBNAME"]
|
"The secret.py file is missing.\n"
|
||||||
DBUSER = os.environ["DBUSER"]
|
"For a development environment, simply copy secret_example.py"
|
||||||
DBPASSWD = os.environ["DBPASSWD"]
|
|
||||||
except KeyError:
|
|
||||||
raise RuntimeError("Secrets missing")
|
|
||||||
|
|
||||||
|
|
||||||
# Other secrets
|
|
||||||
try:
|
|
||||||
from .secret import (
|
|
||||||
SECRET_KEY, RECAPTCHA_PUBLIC_KEY, RECAPTCHA_PRIVATE_KEY, ADMINS,
|
|
||||||
REDIS_PASSWD, REDIS_DB, REDIS_HOST, REDIS_PORT, KFETOPEN_TOKEN,
|
|
||||||
)
|
)
|
||||||
except ImportError:
|
|
||||||
raise RuntimeError("Secrets missing")
|
|
||||||
|
def import_secret(name):
|
||||||
|
"""
|
||||||
|
Shorthand for importing a value from the secret module and raising an
|
||||||
|
informative exception if a secret is missing.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
return getattr(secret, name)
|
||||||
|
except AttributeError:
|
||||||
|
raise RuntimeError("Secret missing: {}".format(name))
|
||||||
|
|
||||||
|
|
||||||
|
SECRET_KEY = import_secret("SECRET_KEY")
|
||||||
|
ADMINS = import_secret("ADMINS")
|
||||||
|
|
||||||
|
DBNAME = import_secret("DBNAME")
|
||||||
|
DBUSER = import_secret("DBUSER")
|
||||||
|
DBPASSWD = import_secret("DBPASSWD")
|
||||||
|
|
||||||
|
REDIS_PASSWD = import_secret("REDIS_PASSWD")
|
||||||
|
REDIS_DB = import_secret("REDIS_DB")
|
||||||
|
REDIS_HOST = import_secret("REDIS_HOST")
|
||||||
|
REDIS_PORT = import_secret("REDIS_PORT")
|
||||||
|
|
||||||
|
RECAPTCHA_PUBLIC_KEY = import_secret("RECAPTCHA_PUBLIC_KEY")
|
||||||
|
RECAPTCHA_PRIVATE_KEY = import_secret("RECAPTCHA_PRIVATE_KEY")
|
||||||
|
|
||||||
|
KFETOPEN_TOKEN = import_secret("KFETOPEN_TOKEN")
|
||||||
|
|
||||||
|
|
||||||
BASE_DIR = os.path.dirname(
|
BASE_DIR = os.path.dirname(
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
SECRET_KEY = 'q()(zn4m63i%5cp4)f+ww4-28_w+ly3q9=6imw2ciu&_(5_4ah'
|
SECRET_KEY = 'q()(zn4m63i%5cp4)f+ww4-28_w+ly3q9=6imw2ciu&_(5_4ah'
|
||||||
RECAPTCHA_PUBLIC_KEY = "DUMMY"
|
ADMINS = None
|
||||||
RECAPTCHA_PRIVATE_KEY = "DUMMY"
|
|
||||||
|
DBUSER = "cof_gestion"
|
||||||
|
DBNAME = "cof_gestion"
|
||||||
|
DBPASSWD = "4KZt3nGPLVeWSvtBZPSM3fSzXpzEU4"
|
||||||
|
|
||||||
REDIS_PASSWD = "dummy"
|
REDIS_PASSWD = "dummy"
|
||||||
REDIS_PORT = 6379
|
REDIS_PORT = 6379
|
||||||
REDIS_DB = 0
|
REDIS_DB = 0
|
||||||
REDIS_HOST = "127.0.0.1"
|
REDIS_HOST = "127.0.0.1"
|
||||||
ADMINS = None
|
|
||||||
|
RECAPTCHA_PUBLIC_KEY = "DUMMY"
|
||||||
|
RECAPTCHA_PRIVATE_KEY = "DUMMY"
|
||||||
|
|
||||||
KFETOPEN_TOKEN = "plop"
|
KFETOPEN_TOKEN = "plop"
|
||||||
|
|
Loading…
Reference in a new issue