本文整理汇总了Python中requests.packages.urllib3.exceptions.InsecureRequestWarning方法的典型用法代码示例。如果您正苦于以下问题:Python exceptions.InsecureRequestWarning方法的具体用法?Python exceptions.InsecureRequestWarning怎么用?Python exceptions.InsecureRequestWarning使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类requests.packages.urllib3.exceptions
的用法示例。
在下文中一共展示了exceptions.InsecureRequestWarning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cli
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def cli(ctx):
"""\b
Welcome to the Wio Command line utility!
https://github.com/Seeed-Studio/wio-cli
For more information Run: wio <command_name> --help
"""
ctx.obj = Wio()
cur_dir = os.path.abspath(os.path.expanduser("~/.wio"))
if not os.path.exists(cur_dir):
text = {"email":"", "token":""}
os.mkdir(cur_dir)
open("%s/config.json"%cur_dir,"w").write(json.dumps(text))
db_file_path = '%s/config.json' % cur_dir
config = json.load(open(db_file_path))
ctx.obj.config = config
signal.signal(signal.SIGINT, sigint_handler)
if not verify:
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
示例2: send_sms
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def send_sms(self, text, **kw):
"""
Send an SMS. Since Free only allows us to send SMSes to ourselves you
don't have to provide your phone number.
"""
params = {
'user': self._user,
'pass': self._passwd,
'msg': text
}
kw.setdefault("verify", False)
if not kw["verify"]:
# remove SSL warning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
res = requests.get(FreeClient.BASE_URL, params=params, **kw)
return FreeResponse(res.status_code)
示例3: main
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def main():
if len(sys.argv) < 4:
usage(sys.argv[0])
# Disable insecure-certificate-warning message
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
base_uri = "https://" + sys.argv[1]
creds = {'user': sys.argv[2],
'pswd': sys.argv[3]}
# This will vary by OEM
result = find_systems_resource(base_uri, creds)
if result['ret'] is True:
check_power_state(base_uri, result['systems_uri'], creds)
else:
print("Error: %s" % result['msg'])
exit(1)
示例4: main
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def main():
if len(sys.argv) < 4:
usage(sys.argv[0])
# Disable insecure-certificate-warning message
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
base_uri = "https://" + sys.argv[1]
creds = {'user': sys.argv[2],
'pswd': sys.argv[3]}
# This will vary by OEM
result = find_systems_resource(base_uri, creds)
if result['ret'] is True:
turn_power_off(base_uri, result['systems_uri'], creds)
else:
print("Error: %s" % result['msg'])
exit(1)
示例5: main
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def main():
if len(sys.argv) < 4:
usage(sys.argv[0])
# Disable insecure-certificate-warning message
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
base_uri = "https://" + sys.argv[1]
creds = {'user': sys.argv[2],
'pswd': sys.argv[3]}
# This will vary by OEM
result = find_systems_resource(base_uri, creds)
if result['ret'] is True:
turn_power_on(base_uri, result['systems_uri'], creds)
else:
print("Error: %s" % result['msg'])
exit(1)
示例6: run
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def run(self):
with open("plugins/wordlists/plugins.txt", "w") as fd:
session = requests.Session()
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
i = 1
plugins_file = open("./plugins/wordlists/plugins.txt", "w")
while True:
paramsGet = {"page":""+str(i)+"","sort":"created_desc"}
headers = {"User-Agent":"curl/7.64.1","Connection":"close","Accept":"*/*"}
response = session.get("https://git.drupalcode.org/groups/project/-/children.json", params=paramsGet, headers=headers,verify=False)
json_st = json.loads(response.content)
if response.status_code == 200:
if len(json_st) == 0:
plugins_file.close()
break
for name in json_st:
print (name['name'])
fd.write(str(name['name']))
fd.write("\n")
i +=1
示例7: post
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def post(*args, **kwargs):
kwargs['verify'] = False
with warnings.catch_warnings():
warnings.simplefilter('ignore', exceptions.InsecureRequestWarning)
warnings.simplefilter('ignore', exceptions.InsecurePlatformWarning)
# if isinstance(self.proxy, dict):
# kwargs['proxies'] = self.proxy
try:
req = requests.post(*args, **kwargs)
except:
return (False, None)
if req.status_code == 200:
return (True, req)
else:
return (False, req)
示例8: get
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def get(*args, **kwargs):
kwargs['verify'] = False
with warnings.catch_warnings():
warnings.simplefilter('ignore', exceptions.InsecureRequestWarning)
warnings.simplefilter('ignore', exceptions.InsecurePlatformWarning)
# if isinstance(self.proxy, dict):
# kwargs['proxies'] = self.proxy
try:
req = requests.get(*args, **kwargs)
except:
return (False, None)
if req.status_code == 200:
return (True, req)
else:
return (False, req)
示例9: request_to_core
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def request_to_core(self, req_type, data, config):
"""
perform different request types to the core
"""
url = self.create_url(config, req_type, self.http)
try:
with warnings.catch_warnings():
warnings.simplefilter("ignore", exceptions.InsecureRequestWarning)
request_to_core = requests.post(url, data=data, verify=False, timeout=30)
logging.info("%s request successfully sent to PRTG Core Server at %s:%s."
% (req_type, config["server"], config["port"]))
logging.debug("Connecting to %s:%s" % (config["server"], config["port"]))
logging.debug("Status Code: %s | Message: %s" % (request_to_core.status_code, request_to_core.text))
return request_to_core
except requests.exceptions.Timeout:
logging.error("%s Timeout: %s" % (req_type, str(data)))
raise
except Exception as req_except:
logging.error("Exception %s!" % req_except)
raise
示例10: __init__
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def __init__(self,
api_path, host,
token,
token_type='Bearer',
tls_verify=True,
enable_pagination=True
):
self.api_path = api_path
self.host = host
self.token = token
self.token_type = token_type
self.tls_verify = tls_verify
self.enable_pagination = enable_pagination
self._cache = RequestCache()
if not self.tls_verify:
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
示例11: __init__
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def __init__(self, config, logger=None):
self._config = config
# Configure logging
if logger is None:
logger = logging.getLogger(self.__module__ + "." + self.__class__.__name__)
logger.setLevel(logging.INFO)
self.logger = logger
if self._config.apiKey is None:
raise ConfigurationException("Missing required property for API key based authentication: auth-key")
if self._config.apiToken is None:
raise ConfigurationException("Missing required property for API key based authentication: auth-token")
# To support development systems this can be overridden to False
if not self._config.verify:
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
示例12: setting
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def setting():
reload(sys)
sys.setdefaultencoding('utf-8')
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
#banner
示例13: __init__
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def __init__(self, cloud_info, inf):
self.cloud = cloud_info
"""Data about the Cloud Provider."""
self.inf = inf
"""Infrastructure this CloudConnector is associated with."""
self.logger = logging.getLogger('CloudConnector')
"""Logger object."""
self.error_messages = ""
"""String with error messages to be shown to the user."""
self.verify_ssl = Config.VERIFI_SSL
"""Verify SSL connections """
if not self.verify_ssl:
# To avoid errors with host certificates
try:
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
except Exception:
pass
try:
# To avoid annoying InsecureRequestWarning messages in some Connectors
import requests.packages
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
except Exception:
pass
示例14: connect
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def connect(self, params):
# Silence warnings and request logging
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
logging.getLogger('urllib3').setLevel(logging.CRITICAL)
username, threatstream_url, api_key = params["username"], \
params["url"], params["api_key"]["secretKey"]
# Set up the base request
self.request.url = threatstream_url + "/api/v1"
self.request.verify = params.get("ssl_verify")
self.request.params = {
"username": username,
"api_key": api_key
}
示例15: get_junos_details
# 需要导入模块: from requests.packages.urllib3 import exceptions [as 别名]
# 或者: from requests.packages.urllib3.exceptions import InsecureRequestWarning [as 别名]
def get_junos_details(dev):
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
healthbot_user = 'jcluser'
healthbot_pwd = 'Juniper!1'
healthbot_server = '100.123.35.0'
headers = { 'Accept' : 'application/json', 'Content-Type' : 'application/json' }
url = 'https://'+ healthbot_server + ':8080/api/v1/device/' + dev +'/'
r = requests.get(url, auth=HTTPBasicAuth(healthbot_user, healthbot_pwd), headers=headers, verify=False)
return r.json()