forked from jhao104/proxy_pool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[update] 使用setting.py替换Config.ini配置文件
- Loading branch information
Showing
15 changed files
with
154 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
------------------------------------------------- | ||
File Name: ConfigGetter | ||
Description : 读取配置 | ||
Author : JHao | ||
date: 2019/2/15 | ||
------------------------------------------------- | ||
Change Activity: | ||
2019/2/15: | ||
------------------------------------------------- | ||
""" | ||
__author__ = 'JHao' | ||
|
||
|
||
from Util.utilClass import LazyProperty | ||
from Config.setting import * | ||
|
||
|
||
class ConfigGetter(object): | ||
""" | ||
get config | ||
""" | ||
|
||
def __init__(self): | ||
pass | ||
|
||
@LazyProperty | ||
def db_type(self): | ||
return DATABASES.get("default", {}).get("TYPE", "SSDB") | ||
|
||
@LazyProperty | ||
def db_name(self): | ||
return DATABASES.get("default", {}).get("NAME", "proxy") | ||
|
||
@LazyProperty | ||
def db_host(self): | ||
return DATABASES.get("default", {}).get("HOST", "127.0.0.1") | ||
|
||
@LazyProperty | ||
def db_port(self): | ||
return DATABASES.get("default", {}).get("PORT", 8080) | ||
|
||
@LazyProperty | ||
def db_password(self): | ||
return DATABASES.get("default", {}).get("PASSWORD", "") | ||
|
||
@LazyProperty | ||
def proxy_getter_functions(self): | ||
return PROXY_GETTER | ||
|
||
@LazyProperty | ||
def host_ip(self): | ||
return SERVER_API.get("HOST", "127.0.0.1") | ||
|
||
@LazyProperty | ||
def host_port(self): | ||
return SERVER_API.get("PORT", 5010) | ||
|
||
|
||
config = ConfigGetter() | ||
|
||
if __name__ == '__main__': | ||
print(config.db_type) | ||
print(config.db_name) | ||
print(config.db_host) | ||
print(config.db_port) | ||
print(config.proxy_getter_functions) | ||
print(config.host_ip) | ||
print(config.host_port) | ||
print(config.db_password) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
------------------------------------------------- | ||
File Name: __init__.py | ||
Description : | ||
Author : J_hao | ||
date: 2017/7/31 | ||
File Name: __init__ | ||
Description : | ||
Author : JHao | ||
date: 2019/2/15 | ||
------------------------------------------------- | ||
Change Activity: | ||
2017/7/31: | ||
2019/2/15: | ||
------------------------------------------------- | ||
""" | ||
__author__ = 'J_hao' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
------------------------------------------------- | ||
File Name: setting.py | ||
Description : 配置文件 | ||
Author : JHao | ||
date: 2019/2/15 | ||
------------------------------------------------- | ||
Change Activity: | ||
2019/2/15: | ||
------------------------------------------------- | ||
""" | ||
|
||
# database config | ||
|
||
DATABASES = { | ||
"default": { | ||
"TYPE": "SSDB", # TYPE SSDB/MONGODB if use redis, only modify the host port, the type should be SSDB | ||
"HOST": "127.0.0.1", | ||
"PORT": 8888, | ||
"NAME": "proxy", | ||
"PASSWORD": "" | ||
|
||
} | ||
} | ||
|
||
# register the proxy getter function | ||
|
||
PROXY_GETTER = [ | ||
"freeProxyFirst", | ||
"freeProxySecond", | ||
# "freeProxyThird", | ||
"freeProxyFourth", | ||
"freeProxyFifth", | ||
# "freeProxySixth" | ||
"freeProxySeventh", | ||
# "freeProxyEight", | ||
# "freeProxyNinth", | ||
"freeProxyTen", | ||
"freeProxyEleven", | ||
"freeProxyTwelve", | ||
# foreign website, outside the wall | ||
"freeProxyWallFirst", | ||
"freeProxyWallSecond", | ||
"freeProxyWallThird" | ||
] | ||
|
||
|
||
# # API config http://127.0.0.1:5010 | ||
|
||
SERVER_API = { | ||
"HOST": "0.0.0.0", # The ip specified which starting the web API | ||
"PORT": 5010 # port number to which the server listens to | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters