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


Python urllib3.disable_warnings方法代码示例

本文整理汇总了Python中urllib3.disable_warnings方法的典型用法代码示例。如果您正苦于以下问题:Python urllib3.disable_warnings方法的具体用法?Python urllib3.disable_warnings怎么用?Python urllib3.disable_warnings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在urllib3的用法示例。


在下文中一共展示了urllib3.disable_warnings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_setcookie_language_value

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def get_setcookie_language_value(tgtUrl,timeout):

    urllib3.disable_warnings()
    tgtUrl = tgtUrl
    try:
        rsp = requests.get(tgtUrl, timeout=timeout, verify=False)
        rsp_setcookie = rsp.headers['Set-Cookie']
        # print rsp.text
        pattern = re.compile(r'(.*?)language=')
        language_pattern = pattern.findall(rsp_setcookie)
        setcookie_language = language_pattern[0].split(' ')[-1].strip() + 'language=en'
        return str(setcookie_language)

    except:
        print str(tgtUrl) + ' get setcookie language value error!'
        return 'get-setcookie-language-value-error' 
开发者ID:theLSA,项目名称:discuz-ml-rce,代码行数:18,代码来源:dz-ml-rce.py

示例2: __init__

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def __init__(self):
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
        requests.packages.urllib3.disable_warnings()

        self.timeout = TIMEOUT
        self.session = requests.Session()
        self.headers = get_ua()

        if COOKIE == 'random':
            plain = ''.join([random.choice('0123456789') for _ in range(8)])
            md5sum = hashlib.md5()
            md5sum.update(plain.encode('utf-8'))
            md5 = md5sum.hexdigest()
            self.headers.update({'Cookie': 'SESSION=' + md5})
        else:
            self.headers.update(COOKIE)

        if SOCKS5:
            ip, port = SOCKS5
            socks.set_default_proxy(socks.SOCKS5, ip, port)
            socket.socket = socks.socksocket 
开发者ID:al0ne,项目名称:Vxscan,代码行数:23,代码来源:Requests.py

示例3: new_recipe

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def new_recipe(requests_session, action_id, server, headers):
    urllib3.disable_warnings()

    # Create a recipe
    recipe_data = {
        "action_id": action_id,
        "arguments": '{"learnMoreMessage":"This field may not be blank.","learnMoreUrl":"This field may not be blank.","message":"This field may not be blank.","postAnswerUrl":"This field may not be blank.","surveyId":"'
        + str(uuid.uuid4())
        + '","thanksMessage":"This field may not be blank."}',
        "name": "test recipe",
        "extra_filter_expression": "counter == 0",
        "enabled": "false",
    }

    response = requests_session.post(
        urljoin(server, "/api/v3/recipe/"), data=recipe_data, headers=headers
    )
    data = response.json()
    return {"id": data["id"], "latest_revision_id": data["latest_revision"]["id"]} 
开发者ID:mozilla,项目名称:normandy,代码行数:21,代码来源:helpers.py

示例4: client

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def client(self):
        cls = self.__class__
        if cls._client is None:
            if self.verify_ssl is False:
                import requests
                requests.packages.urllib3.disable_warnings()
                import urllib3
                urllib3.disable_warnings()

            if self.username and self.password:
                self.log.debug("Creating Kubernetes client from username and password")
                cls._client = KubernetesClient.from_username_password(self.host, self.username, self.password,
                                                                      verify_ssl=self.verify_ssl)
            else:
                self.log.debug("Creating Kubernetes client from Service Account")
                cls._client = KubernetesClient.from_service_account(self.host, verify_ssl=self.verify_ssl)
        return cls._client 
开发者ID:danielfrg,项目名称:jupyterhub-kubernetes_spawner,代码行数:19,代码来源:spawner.py

示例5: configure_logging

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def configure_logging():
    logging.basicConfig(
        level=logging.INFO,
        format='%(asctime)s - %(process)d - [%(levelname)s] %(message)s',
    )

    # Suppress boto INFO.
    logging.getLogger('boto3').setLevel(logging.WARNING)
    logging.getLogger('botocore').setLevel(logging.WARNING)
    logging.getLogger('nose').setLevel(logging.WARNING)

    logging.getLogger("requests").setLevel(logging.WARNING)
    logging.getLogger("urllib3").setLevel(logging.WARNING)

    import urllib3
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

    # import botocore.vendored.requests.packages.urllib3 as urllib3
    urllib3.disable_warnings(botocore.vendored.requests.packages.urllib3.exceptions.InsecureRequestWarning) 
开发者ID:andresriancho,项目名称:enumerate-iam,代码行数:21,代码来源:main.py

示例6: send

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def send(self, url, method="GET", payload=None, headers=None, cookies=None):
        # requests session
        output = Services.get('output')
        request = Session()
        prepped=self.prepare_request(url,method,payload,headers,cookies)
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
        try:
            resp=request.send(
                prepped,
                timeout=self.timeout,
                proxies={
                    'http': self.proxy,
                    'https': self.proxy,
                    'ftp': self.proxy,
                },
                allow_redirects=self.redirect,
                verify=False)
            return resp
        except TimeoutError:
            output.error("Timeout error on the URL: %s" % url)
        except RequestException as err:
            output.error("Error while trying to contact the website: \n {0}\n".format(err))
            raise(err) 
开发者ID:shenril,项目名称:Sitadel,代码行数:25,代码来源:request.py

示例7: get_e2e_configuration

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def get_e2e_configuration():
    config = Configuration()
    config.host = None
    if os.path.exists(
            os.path.expanduser(kube_config.KUBE_CONFIG_DEFAULT_LOCATION)):
        kube_config.load_kube_config(client_configuration=config)
    else:
        print('Unable to load config from %s' %
              kube_config.KUBE_CONFIG_DEFAULT_LOCATION)
        for url in ['https://%s:8443' % DEFAULT_E2E_HOST,
                    'http://%s:8080' % DEFAULT_E2E_HOST]:
            try:
                urllib3.PoolManager().request('GET', url)
                config.host = url
                config.verify_ssl = False
                urllib3.disable_warnings()
                break
            except urllib3.exceptions.HTTPError:
                pass
    if config.host is None:
        raise unittest.SkipTest('Unable to find a running Kubernetes instance')
    print('Running test against : %s' % config.host)
    config.assert_hostname = False
    return config 
开发者ID:kubernetes-client,项目名称:python,代码行数:26,代码来源:base.py

示例8: __init__

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def __init__(self, url, user_agent, cookies_string=False, custom_header=False, insecure_ssl='false', proxy=False):
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
        self.__url = url
        self.__headers = dict()
        self.__headers['User-Agent'] = self.__default_user_agent if user_agent == 'default' else user_agent
        if cookies_string:
            self.__headers['Cookie'] = cookies_string
        if custom_header:
            self.__parse_custom_header(custom_header)
        self.__verify = 'CERT_REQUIRED' if insecure_ssl == 'false' else 'CERT_NONE'
        if proxy:
            proxy_type = proxy.split('://')[0]
            if proxy_type == 'http' or proxy_type == 'https':
                self.__request_obj = urllib3.ProxyManager(proxy, ssl_version=ssl.PROTOCOL_TLSv1,
                                                          timeout=self.__request_timeout, cert_reqs=self.__verify)
            else:
                self.__request_obj = SOCKSProxyManager(proxy, ssl_version=ssl.PROTOCOL_TLSv1,
                                                       timeout=self.__request_timeout, cert_reqs=self.__verify)
        else:
            self.__request_obj = urllib3.PoolManager(ssl_version=ssl.PROTOCOL_TLSv1, timeout=self.__request_timeout,
                                                     cert_reqs=self.__verify)
        # print (vars(self)) 
开发者ID:antonioCoco,项目名称:SharPyShell,代码行数:24,代码来源:Request.py

示例9: send_turing

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def send_turing(key, info, userid):
    """
    send request to Turing robot, and get a response
    :param key: TURING_KEY
    :param info: the message from user
    :param userid: chat_id, for context parse
    :return: response from Turing Bot, in text.
    """
    return requests.get(' http://115.159.180.177:6789/chat?text={}'.format(info)).json()['text']

    data = {
        "key": key,
        "info": info,
        "userid": userid

    }

    # TODO: use local cert to prevent from MITM, worst idea ever.
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
    url = 'https://www.tuling123.com/openapi/api'
    result = requests.post(url, json=data, verify=False).text
    return json.loads(result).get('text') 
开发者ID:BennyThink,项目名称:ExpressBot,代码行数:24,代码来源:turing.py

示例10: grimoire_con

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def grimoire_con(insecure=True, conn_retries=MAX_RETRIES_ON_CONNECT, total=MAX_RETRIES):
    conn = requests.Session()
    # {backoff factor} * (2 ^ ({number of total retries} - 1))
    # conn_retries = 21  # 209715.2 = 2.4d
    # total covers issues like 'ProtocolError('Connection aborted.')
    # Retry when there are errors in HTTP connections
    retries = urllib3.util.Retry(total=total, connect=conn_retries, read=MAX_RETRIES_ON_READ,
                                 redirect=MAX_RETRIES_ON_REDIRECT, backoff_factor=BACKOFF_FACTOR,
                                 method_whitelist=False, status_forcelist=STATUS_FORCE_LIST)
    adapter = requests.adapters.HTTPAdapter(max_retries=retries)
    conn.mount('http://', adapter)
    conn.mount('https://', adapter)

    if insecure:
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
        conn.verify = False

    return conn 
开发者ID:chaoss,项目名称:grimoirelab-elk,代码行数:20,代码来源:utils.py

示例11: wait_for_workflow_execution

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def wait_for_workflow_execution(self, workflow_execution, wait_seconds):
        headers = {"Authorization": self.env_vars['token']}

        # disable unsigned HTTPS certificate warnings
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

        workflow_id = workflow_execution['Id']

        # It might take a few seconds for the step function to start, so we'll try to get the execution arn a few times
        # before giving up
        retries=0
        # FIXME retry_limit = ceil(wait_seconds/5)
        retry_limit = 60
        while(retries<retry_limit):
            retries+=1
            print("Checking workflow execution status for workflow {}".format(workflow_id))
            workflow_execution_response = requests.get(self.stack_resources["WorkflowApiEndpoint"]+'/workflow/execution/'+workflow_id, verify=False, headers=headers)
            workflow_execution = workflow_execution_response.json()
            assert workflow_execution_response.status_code == 200
            if workflow_execution["Status"] in ["Complete", "Error"]:
                break
            time.sleep(5)

        return workflow_execution 
开发者ID:awslabs,项目名称:aws-media-insights-engine,代码行数:26,代码来源:conftest.py

示例12: operations

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def operations(api, session_operation_configs, api_schema):
    api = api()
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

    print("Creating test operations")
    for config in session_operation_configs:

        print("\nOPERATION CONFIGURATION: {}".format(config))

        # Create the operation
        create_operation_response = api.create_operation_request(config)
        operation = create_operation_response.json()
        assert create_operation_response.status_code == 200
        validation.schema(operation, api_schema["create_operation_response"])

    # yield session_operation_configs

    # for config in session_operation_configs:
    #     #Delete the operation
    #     operation = {}
    #     operation["Name"] = config["Name"]

    #     delete_operation_response = api.delete_operation_request(operation)
    #     assert delete_operation_response.status_code == 200 
开发者ID:awslabs,项目名称:aws-media-insights-engine,代码行数:26,代码来源:conftest.py

示例13: stages

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def stages(api, operations, session_stage_configs, api_schema):
    api = api()
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

    print("Creating test stages")
    for config in session_stage_configs:

        print("\nSTAGE CONFIGURATION: {}".format(config))

        # Create the stage
        create_stage_response = api.create_stage_request(config)
        stage = create_stage_response.json()

        assert create_stage_response.status_code == 200
        validation.schema(stage, api_schema["create_stage_response"])

    # yield session_stage_configs

    # for config in session_stage_configs:
    #     #Delete the stage
    #     stage = {}
    #     stage["Name"] = config["Name"]

    #     delete_stage_response = api.delete_stage_request(stage)
    #     assert delete_stage_response.status_code == 200 
开发者ID:awslabs,项目名称:aws-media-insights-engine,代码行数:27,代码来源:conftest.py

示例14: do_url_request

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def do_url_request(self, url, body=None, method='GET'):
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
        currentHeaders = self.contentTypeHeaders

        try:
            if method == 'GET':
                res = requests.get(url, headers=currentHeaders, verify=False, timeout=2)
            elif method == 'POST':
                res = requests.post(url, data=body, headers=currentHeaders, verify=False)
            else:
                raise ValueError("Method %s is not supported right now." % method)

            self.response = res.status_code
            content = res.text
        except Exception:
            print("Can't perform request to %s" % (url))
            return ""

        return content 
开发者ID:opentaps,项目名称:opentaps_seas,代码行数:21,代码来源:client.py

示例15: _generate_audio_file

# 需要导入模块: import urllib3 [as 别名]
# 或者: from urllib3 import disable_warnings [as 别名]
def _generate_audio_file(self):
        """
        Generic method used as a Callback in TTSModule
            - must provided the audio file and write it on the disk

        .. raises:: FailToLoadSoundFile
        """

        # Since the gTTS lib disabled the SSL verification we get rid of insecure request warning
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
        
        tts = gTTS(text=self.words, lang=self.language)
        
        # OK we get the audio we can write the sound file
        tts.save(self.file_path)
        
        # Re enable the warnings to avoid affecting the whole kalliope process 
        warnings.resetwarnings() 
开发者ID:kalliope-project,项目名称:kalliope,代码行数:20,代码来源:googletts.py


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