forked from jhao104/proxy_pool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configHandler.py
62 lines (49 loc) · 1.5 KB
/
configHandler.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
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
File Name: configHandler
Description :
Author : JHao
date: 2020/6/22
-------------------------------------------------
Change Activity:
2020/6/22:
-------------------------------------------------
"""
__author__ = 'JHao'
import os
import setting
from util.singleton import Singleton
from util.lazyProperty import LazyProperty
from util.six import reload_six, withMetaclass
class ConfigHandler(withMetaclass(Singleton)):
def __init__(self):
pass
@LazyProperty
def serverHost(self):
return os.environ.get("HOST", setting.HOST)
@LazyProperty
def serverPort(self):
return os.environ.get("PORT", setting.PORT)
@LazyProperty
def dbConn(self):
return os.getenv("DB_CONN", setting.DB_CONN)
@LazyProperty
def tableName(self):
return os.getenv("TABLE_NAME", setting.TABLE_NAME)
@property
def fetchers(self):
reload_six(setting)
return setting.PROXY_FETCHER
@LazyProperty
def verifyUrl(self):
return os.getenv("VERIFY_URL", setting.VERIFY_URL)
@LazyProperty
def verifyTimeout(self):
return os.getenv("VERIFY_TIMEOUT", setting.VERIFY_TIMEOUT)
@LazyProperty
def maxFailCount(self):
return os.getenv("MAX_FAIL_COUNT", setting.MAX_FAIL_COUNT)
@LazyProperty
def timezone(self):
return os.getenv("TIMEZONE", getattr(setting, 'TIMEZONE', None))