-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathconfig.py
69 lines (55 loc) · 2.38 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
# -*- coding: utf-8 -*-
# Author: G.J.J. van den Burg <[email protected]>
# License: See LICENSE file
# Copyright: 2020 (c) The Alan Turing Institute
"""Configuration for the AnnotateChange app
Almost all configuration options are expected to be supplied through
environment variables.
"""
import os
BASEDIR = os.path.abspath(os.path.dirname(__file__))
class Config(object):
SECRET_KEY = os.environ.get("SECRET_KEY") or "you-will-never-guess"
DB_TYPE = os.environ.get("DB_TYPE") or "sqlite3"
if DB_TYPE == "mysql":
SQLALCHEMY_DATABASE_URI = "mysql+pymysql://{username}:{password}@{host}:{port}/{database}".format(
username=os.environ.get("AC_MYSQL_USER"),
password=os.environ.get("AC_MYSQL_PASSWORD"),
host=os.environ.get("AC_MYSQL_HOST"),
port=os.environ.get("AC_MYSQL_PORT"),
database=os.environ.get("AC_MYSQL_DATABASE"),
)
else:
SQLALCHEMY_DATABASE_URI = "sqlite:///{filepath}".format(
filepath=os.path.join(
BASEDIR, os.environ.get("SQL3_FILENAME") or "app.db"
)
)
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 = [
x.strip()
for x in os.environ.get("ADMIN_EMAILS", "").split(";")
if x.strip()
]
# these should be used relative to the instance path
DATASET_DIR = "datasets"
TEMP_DIR = "tmp"
# task distribution settings
TASKS_MAX_PER_USER = int(os.environ.get("TASKS_MAX_PER_USER") or 50)
TASKS_NUM_PER_DATASET = int(os.environ.get("TASKS_NUM_PER_DATASET") or 5)
# user emails allowed
USER_EMAIL_DOMAINS = os.environ.get("USER_EMAIL_DOMAINS") or ""
USER_EMAIL_DOMAINS = [
x.strip() for x in USER_EMAIL_DOMAINS.split(";") if x.strip()
]
USER_EMAIL_DOMAINS = None if not USER_EMAIL_DOMAINS else USER_EMAIL_DOMAINS
USER_EMAILS = os.environ.get("USER_EMAILS") or ""
USER_EMAILS = [x.strip() for x in USER_EMAILS.split(";") if x.strip()]
USER_EMAILS = None if not USER_EMAILS else USER_EMAILS
# other
ACCEPTING_REGISTRATION = bool(int(os.environ.get('ACCEPTING_REGISTRATION', 0))) or False