测试插件
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -6,6 +6,12 @@ test.py
|
|||||||
*.yaml
|
*.yaml
|
||||||
*.db
|
*.db
|
||||||
|
|
||||||
|
## user file
|
||||||
|
token_cache.bin
|
||||||
|
|
||||||
|
### plugin file
|
||||||
|
custom_plugins/*
|
||||||
|
|
||||||
### venv template
|
### venv template
|
||||||
# Virtualenv
|
# Virtualenv
|
||||||
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
|
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import os
|
|||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
|
|
||||||
__BASE_PATH = os.getcwd()
|
__BASE_PATH = os.getcwd()
|
||||||
__CONFIG_PATH = os.path.join(__BASE_PATH, 'config')
|
__CONFIG_PATH = os.path.join(__BASE_PATH, 'config')
|
||||||
__CONFIG_NAME = 'test.yaml'
|
__CONFIG_NAME = 'test.yaml'
|
||||||
@@ -61,3 +62,14 @@ class Config:
|
|||||||
self.__CONFIG_DICT['PROXY'] = new_proxy
|
self.__CONFIG_DICT['PROXY'] = new_proxy
|
||||||
with open(os.path.join(self.__CONFIG_PATH, self.__CONFIG_NAME), 'w') as f:
|
with open(os.path.join(self.__CONFIG_PATH, self.__CONFIG_NAME), 'w') as f:
|
||||||
f.write(yaml.safe_dump(self.__CONFIG_DICT, sort_keys=False))
|
f.write(yaml.safe_dump(self.__CONFIG_DICT, sort_keys=False))
|
||||||
|
|
||||||
|
def get_config(self, config_name, default=None):
|
||||||
|
try:
|
||||||
|
return self.__CONFIG_DICT[config_name]
|
||||||
|
except:
|
||||||
|
return default
|
||||||
|
|
||||||
|
def set_config(self, config_name, value):
|
||||||
|
self.__CONFIG_DICT[config_name] = value
|
||||||
|
with open(os.path.join(self.__CONFIG_PATH, self.__CONFIG_NAME), 'w') as f:
|
||||||
|
f.write(yaml.safe_dump(self.__CONFIG_DICT, sort_keys=False))
|
||||||
@@ -34,7 +34,7 @@ class RequestWithProxy:
|
|||||||
|
|
||||||
def get(self, url, headers=None):
|
def get(self, url, headers=None):
|
||||||
try:
|
try:
|
||||||
if url.replace("https://", "").replace("http://", "") in self.__no_proxy:
|
if url.replace("https://", "").replace("http://", "").splice('/')[0] in self.__no_proxy:
|
||||||
r = requests.get(url=url, headers=headers)
|
r = requests.get(url=url, headers=headers)
|
||||||
else:
|
else:
|
||||||
r = requests.get(url=url, headers=headers, proxies=self.__proxies)
|
r = requests.get(url=url, headers=headers, proxies=self.__proxies)
|
||||||
|
|||||||
Reference in New Issue
Block a user