-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
72 lines (57 loc) · 3.6 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
import os
from pathlib import Path
basedir = os.path.abspath(os.path.dirname(__file__))
class Config(object):
# basic Flask settings
BASE_DIR = Path(__file__).parent.parent
SECRET_KEY = os.environ.get('SECRET_KEY') or 'you-will-never-guess'
# SQL-Alchemy settings
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL', '').replace(
'postgres://', 'postgresql://') or \
'sqlite:///' + os.path.join(basedir, 'app.db')
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_POOL_SIZE=int(os.environ.get("SQLALCHEMY_POOL_SIZE"))
SQLALCHEMY_POOL_TIMEOUT=int(os.environ.get("SQLALCHEMY_POOL_TIMEOUT"))
SQLALCHEMY_ECHO=os.environ.get("SQLALCHEMY_ECHO", "false")
if SQLALCHEMY_ECHO == "true":
SQLALCHEMY_ECHO = True
else:
SQLALCHEMY_ECHO = False
TIMEZONE = os.environ.get("TIMEZONE", "America/Chicago")
# Redis and RabbitMQ settings.
# by default, we use Redis as the backend and RabbitMQ (via cloudamqp) as the broker.
# but these can also each have distinct values in the environment settings.
REDIS_URL = os.environ.get("REDIS_URL", "redis://127.0.0.1:6379/0")
if REDIS_URL.startswith("rediss://") is True and REDIS_URL.endswith("?ssl_cert_reqs=none") is False:
REDIS_URL = REDIS_URL + "?ssl_cert_reqs=none"
CLOUDAMQP_URL = os.environ.get("CLOUDAMQP_URL", "amqp://guest:[email protected]:5672")
CELERY_BROKER_URL = os.environ.get("CELERY_BROKER_URL", CLOUDAMQP_URL)
RESULT_BACKEND = os.environ.get("RESULT_BACKEND", REDIS_URL)
#CELERY_RESULT_BACKEND = RESULT_BACKEND # this is deprecated. need to make sure that heroku doesn't complain about it being missing.
REDBEAT_REDIS_URL = os.environ.get("REDBEAT_REDIS_URL", REDIS_URL)
CACHE_REDIS_URL = os.environ.get("CACHE_REDIS_URL", REDIS_URL)
# Cache settings
CACHE_TYPE = os.environ.get("CACHE_TYPE", "RedisCache")
CACHE_DEFAULT_TIMEOUT = os.environ.get("CACHE_DEFAULT_TIMEOUT", 500)
QUERY_LIST_CACHE_KEY = os.environ.get("QUERY_LIST_CACHE_KEY", "")
ELECTION_DAY_CACHE_TIMEOUT = os.environ.get("ELECTION_DAY_CACHE_TIMEOUT", os.environ.get("CACHE_DEFAULT_TIMEOUT", 500))
# other apis
BOUNDARY_SERVICE_URL = os.environ.get('BOUNDARY_SERVICE_URL', 'https://represent-minnesota.herokuapp.com')
GEOCODER_MAPQUEST_KEY = os.environ.get('GEOCODER_MAPQUEST_KEY', '')
# Scraper settings
DEFAULT_SCRAPE_FREQUENCY = int(os.environ.get("DEFAULT_SCRAPE_FREQUENCY", 86400))
ELECTION_DATE_OVERRIDE = os.environ.get("ELECTION_DATE_OVERRIDE", None)
ELECTION_DAY_RESULT_SCRAPE_FREQUENCY = int(os.environ.get("ELECTION_DAY_RESULT_SCRAPE_FREQUENCY", 60))
ELECTION_DAY_RESULT_HOURS_START = os.environ.get("ELECTION_DAY_RESULT_HOURS_START", "")
ELECTION_DAY_RESULT_HOURS_END = os.environ.get("ELECTION_DAY_RESULT_HOURS_END", "")
ELECTION_DAY_RESULT_DEFAULT_START_TIME = int(os.environ.get("ELECTION_DAY_RESULT_DEFAULT_START_TIME", 00))
ELECTION_DAY_RESULT_DEFAULT_DURATION_HOURS = int(os.environ.get("ELECTION_DAY_RESULT_DEFAULT_DURATION_HOURS", 48))
ELECTION_RESULT_DATETIME_OVERRIDDEN = os.environ.get("ELECTION_RESULT_DATETIME_OVERRIDDEN", "")
# Google Sheet parser settings
PARSER_API_CACHE_TIMEOUT = os.environ.get("PARSER_API_CACHE_TIMEOUT", 500)
PARSER_API_KEY = os.environ.get("PARSER_API_KEY", "")
AUTHORIZE_API_URL = os.environ.get("AUTHORIZE_API_URL", "")
PARSER_API_URL = os.environ.get("PARSER_API_URL", "")
OVERWRITE_API_URL = os.environ.get("OVERWRITE_API_URL", "")
PARSER_STORE_IN_S3 = os.environ.get("PARSER_STORE_IN_S3", "")
PARSER_BYPASS_API_CACHE = os.environ.get("PARSER_BYPASS_API_CACHE", "false")