当前位置: 首页>>代码示例>>Python>>正文


Python exceptions.InsecureRequestWarning方法代码示例

本文整理汇总了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) 
开发者ID:Seeed-Studio,项目名称:wio-cli,代码行数:23,代码来源:wio.py

示例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) 
开发者ID:bfontaine,项目名称:freesms,代码行数:22,代码来源:__init__.py

示例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) 
开发者ID:jose-delarosa,项目名称:sysadmin-tools,代码行数:21,代码来源:get-power-state.py

示例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) 
开发者ID:jose-delarosa,项目名称:sysadmin-tools,代码行数:21,代码来源:turn-power-off.py

示例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) 
开发者ID:jose-delarosa,项目名称:sysadmin-tools,代码行数:21,代码来源:turn-power-on.py

示例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 
开发者ID:immunIT,项目名称:drupwn,代码行数:22,代码来源:Update.py

示例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) 
开发者ID:InQuest,项目名称:omnibus,代码行数:20,代码来源:http.py

示例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) 
开发者ID:InQuest,项目名称:omnibus,代码行数:20,代码来源:http.py

示例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 
开发者ID:PRTG,项目名称:PythonMiniProbe,代码行数:22,代码来源:miniprobe.py

示例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) 
开发者ID:nephila,项目名称:python-taiga,代码行数:18,代码来源:requestmaker.py

示例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) 
开发者ID:ibm-watson-iot,项目名称:iot-python,代码行数:22,代码来源:common.py

示例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 
开发者ID:se55i0n,项目名称:Webfinger,代码行数:8,代码来源:config.py

示例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 
开发者ID:grycap,项目名称:im,代码行数:28,代码来源:CloudConnector.py

示例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
        } 
开发者ID:rapid7,项目名称:insightconnect-plugins,代码行数:16,代码来源:connection.py

示例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() 
开发者ID:ksator,项目名称:junos_monitoring_with_healthbot,代码行数:11,代码来源:enable_a_disabled_interface.py


注:本文中的requests.packages.urllib3.exceptions.InsecureRequestWarning方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。