-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
51 lines (40 loc) · 1.71 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
#!/usr/bin/env python
# encoding: utf-8
import os
from threading import Thread
from typing import Union, Optional
from dotenv import load_dotenv
from peewee import DatabaseProxy # type: ignore
class BaseConfig:
pass
class DevelopmentConfig(BaseConfig):
load_dotenv()
DATABASE_USER: Optional[str] = os.environ.get("DEV_DB_USER")
DATABASE_PASS: Optional[str] = os.environ.get("DEV_DB_PASSWORD")
DATABASE_HOST: Optional[str] = os.environ.get("DEV_DB_HOST")
DATABASE_PORT: int = int(os.environ.get("DEV_DB_PORT", 3306))
DATABASE_NAME: Optional[str] = os.environ.get("DEV_DB_NAME")
DATABASE_CHARSET: Optional[str] = os.environ.get("DEV_DB_CHARSET")
API_URL: Optional[str] = os.environ.get("DEV_API_URL")
class ProductionConfig(BaseConfig):
load_dotenv()
DATABASE_USER: Optional[str] = os.environ.get("PROD_DB_USER")
DATABASE_PASS: Optional[str] = os.environ.get("PROD_DB_PASSWORD")
DATABASE_HOST: Optional[str] = os.environ.get("PROD_DB_HOST")
DATABASE_PORT: int = int(os.environ.get("PROD_DB_PORT", 3306))
DATABASE_NAME: Optional[str] = os.environ.get("PROD_DB_NAME")
DATABASE_CHARSET: Optional[str] = os.environ.get("PROD_DB_CHARSET")
API_URL: Optional[str] = os.environ.get("PROD_API_URL")
configs = {
'development': DevelopmentConfig,
'production': ProductionConfig,
'default': DevelopmentConfig
}
class Application(object):
setting: Union[DevelopmentConfig, ProductionConfig, None] = None
database_proxy: Optional[DatabaseProxy] = None
otc_ex_bytecode_hex: str = ""
consuming_thread: Optional[Thread] = None
consuming_thread_running: bool = False
statistics_thread: Optional[Thread] = None
statistics_thread_running: bool = False