ogn-python/config.py

70 wiersze
2.3 KiB
Python
Czysty Zwykły widok Historia

2020-05-30 09:48:54 +00:00
import os
2020-11-22 07:55:19 +00:00
2020-05-30 09:48:54 +00:00
class BaseConfig:
SECRET_KEY = "i-like-ogn"
2020-11-22 07:55:19 +00:00
2020-05-30 09:48:54 +00:00
# Flask-Cache stuff
2020-11-25 10:14:36 +00:00
CACHE_TYPE = "redis"
2020-05-30 09:48:54 +00:00
CACHE_DEFAULT_TIMEOUT = 300
2020-11-22 07:55:19 +00:00
2020-05-30 09:48:54 +00:00
# Redis stuff
REDIS_URL = "redis://localhost:6379/0"
2020-11-22 07:55:19 +00:00
2020-05-30 09:48:54 +00:00
# Celery stuff
2020-10-27 19:46:14 +00:00
BROKER_URL = os.environ.get("BROKER_URL", REDIS_URL)
2020-05-30 09:48:54 +00:00
CELERY_RESULT_BACKEND = os.environ.get("CELERY_RESULT_BACKEND", REDIS_URL)
2020-10-27 19:46:14 +00:00
APRS_USER = "OGNPYTHON"
2020-05-30 09:48:54 +00:00
# Upload configuration
MAX_CONTENT_LENGTH = 1024 * 1024 # max. 1MB
UPLOAD_EXTENSIONS = ['.csv']
UPLOAD_PATH = 'uploads'
2020-11-22 07:55:19 +00:00
2020-05-30 09:48:54 +00:00
class DefaultConfig(BaseConfig):
SQLALCHEMY_DATABASE_URI = os.environ.get("SQLALCHEMY_DATABASE_URI", "postgresql://postgres:postgres@localhost:5432/ogn")
SQLALCHEMY_TRACK_MODIFICATIONS = False
2020-11-22 07:55:19 +00:00
2020-05-30 09:48:54 +00:00
# Celery beat stuff
from celery.schedules import crontab
from datetime import timedelta
2020-10-27 19:46:14 +00:00
CELERYBEAT_SCHEDULE = {
2020-11-17 13:58:23 +00:00
"transfer_to_database": {"task": "transfer_to_database", "schedule": timedelta(minutes=1)},
"update_statistics": {"task": "update_statistics", "schedule": timedelta(minutes=5)},
"update_takeoff_landings": {"task": "update_takeoff_landings", "schedule": timedelta(minutes=1), "kwargs": {"last_minutes": 20}},
"update_logbook": {"task": "update_logbook", "schedule": timedelta(minutes=1)},
"update_logbook_previous_day": {"task": "update_logbook", "schedule": crontab(hour=1, minute=0), "kwargs": {"day_offset": -1}},
"update_ddb_daily": {"task": "import_ddb", "schedule": timedelta(days=1)},
#"update_logbook_max_altitude": {"task": "update_logbook_max_altitude", "schedule": timedelta(minutes=1), "kwargs": {"offset_days": 0}},
2020-11-22 07:55:19 +00:00
2020-10-27 19:46:14 +00:00
#"purge_old_data": {"task": "purge_old_data", "schedule": timedelta(hours=1), "kwargs": {"max_hours": 48}},
2020-05-30 09:48:54 +00:00
}
2020-11-25 08:39:10 +00:00
FLASK_PROFILER = {
"enabled": True,
"storage": {
"engine": "sqlalchemy",
"db_url": SQLALCHEMY_DATABASE_URI
},
"ignore": [
"^/static/.*"
]
}
2020-11-22 07:55:19 +00:00
2020-05-30 09:48:54 +00:00
class DevelopmentConfig(BaseConfig):
SQLALCHEMY_DATABASE_URI = "postgresql://postgres:postgres@localhost:5432/ogn_test"
SQLALCHEMY_TRACK_MODIFICATIONS = False
2020-10-27 19:46:14 +00:00
SQLALCHEMY_ECHO = False
2020-05-30 09:48:54 +00:00
2020-11-22 07:55:19 +00:00
2020-05-30 09:48:54 +00:00
configs = {
'default': DefaultConfig,
2020-10-27 19:46:14 +00:00
'development': DevelopmentConfig,
'testing': DevelopmentConfig
2020-11-22 07:55:19 +00:00
}