forked from jhao104/proxy_pool
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configHandler.py
79 lines (61 loc) · 1.95 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# -*- 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 httpUrl(self):
return os.getenv("HTTP_URL", setting.HTTP_URL)
@LazyProperty
def httpsUrl(self):
return os.getenv("HTTPS_URL", setting.HTTPS_URL)
@LazyProperty
def verifyTimeout(self):
return int(os.getenv("VERIFY_TIMEOUT", setting.VERIFY_TIMEOUT))
# @LazyProperty
# def proxyCheckCount(self):
# return int(os.getenv("PROXY_CHECK_COUNT", setting.PROXY_CHECK_COUNT))
@LazyProperty
def maxFailCount(self):
return int(os.getenv("MAX_FAIL_COUNT", setting.MAX_FAIL_COUNT))
# @LazyProperty
# def maxFailRate(self):
# return int(os.getenv("MAX_FAIL_RATE", setting.MAX_FAIL_RATE))
@LazyProperty
def poolSizeMin(self):
return int(os.getenv("POOL_SIZE_MIN", setting.POOL_SIZE_MIN))
@LazyProperty
def timezone(self):
return os.getenv("TIMEZONE", setting.TIMEZONE)