-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
46 lines (36 loc) · 1.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
import os
import logging
SERVER_PORT = int(os.getenv('SERVER_PORT', 5000))
MYSQL_HOST = os.getenv('MYSQL_HOST', '')
MYSQL_PORT = int(os.getenv('MYSQL_PORT', 0))
MYSQL_USERNAME = os.getenv('MYSQL_USERNAME', '')
MYSQL_PASSWORD = os.getenv('MYSQL_PASSWORD', '')
MYSQL_DATABASE = os.getenv('MYSQL_DATABASE', '')
INFLUXDB = {
'host': os.getenv('INFLUXDB_HOST', ''),
'port': int(os.getenv('INFLUXDB_PORT', 0)),
'username': os.getenv('INFLUXDB_USERNAME', ''),
'password': os.getenv('INFLUXDB_PASSWORD', ''),
'db': os.getenv('INFLUXDB_DATABASE', ''),
}
ALGALON = {
'csrf_token': os.getenv('ALGALON_CSRF_TOKEN', ''),
'dns': os.getenv('ALGALON_DSN', ''),
}
LOG_LEVEL = getattr(logging, os.getenv('LOG_LEVEL', 'info').upper())
LOG_FILE = os.getenv('LOG_FILE', '')
LOG_FORMAT = os.getenv('LOG_FORMAT', '%(levelname)s:%(asctime)s:%(message)s')
DEBUG = int(os.getenv('DEBUG', 0))
POLL_INTERVAL = int(os.getenv('POLL_INTERVAL', 10))
try:
from override_config import *
except ImportError:
pass
SQLALCHEMY_DATABASE_URI = 'mysql://%s:%s@%s:%d/%s' % (
MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_HOST, MYSQL_PORT, MYSQL_DATABASE)
def init_logging():
args = {'level': LOG_LEVEL}
if LOG_FILE:
args['filename'] = LOG_FILE
args['format'] = LOG_FORMAT
logging.basicConfig(**args)