當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。