Python urllib3.disable_warnings() Examples
The following are 30
code examples of urllib3.disable_warnings().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
urllib3
, or try the search function
.
Example #1
Source File: dz-ml-rce.py From discuz-ml-rce with MIT License | 7 votes |
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'
Example #2
Source File: googletts.py From kalliope with GNU General Public License v3.0 | 6 votes |
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()
Example #3
Source File: main.py From enumerate-iam with GNU General Public License v3.0 | 6 votes |
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)
Example #4
Source File: request.py From Sitadel with GNU General Public License v3.0 | 6 votes |
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)
Example #5
Source File: base.py From python with Apache License 2.0 | 6 votes |
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
Example #6
Source File: test_bad_urllib3_module_attribute_use.py From dlint with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_bad_urllib3_module_attribute_usage_from_import(self): python_node = self.get_ast_node( """ from urllib3 import disable_warnings disable_warnings() """ ) linter = dlint.linters.BadUrllib3ModuleAttributeUseLinter() linter.visit(python_node) result = linter.get_results() expected = [ dlint.linters.base.Flake8Result( lineno=3, col_offset=0, message=dlint.linters.BadUrllib3ModuleAttributeUseLinter._error_tmpl ), ] assert result == expected
Example #7
Source File: helpers.py From normandy with Mozilla Public License 2.0 | 6 votes |
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"]}
Example #8
Source File: request.py From EasY_HaCk with Apache License 2.0 | 6 votes |
def send(self,method,url,params=None,data=None,headers=None): if headers is None: headers={} headers['User-Agent'] = Request.agent try: session = requests.Session() req = urllib3.disable_warnings( urllib3.exceptions.InsecureRequestWarning ) req = requests.request( method = method.upper(), url = url, params = params, data = data, allow_redirects = True, verify = False ) return req except Exception as e: exit(warn('Failed to establish a new connection'))
Example #9
Source File: session.py From python-panasonic-comfort-cloud with MIT License | 6 votes |
def __init__(self, username, password, tokenFileName='~/.panasonic-token', raw=False, verifySsl=True): self._username = username self._password = password self._tokenFileName = os.path.expanduser(tokenFileName) self._vid = None self._groups = None self._devices = None self._deviceIndexer = {} self._raw = raw if verifySsl == False: urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) self._verifySsl = verifySsl else: self._verifySsl = os.path.join(os.path.dirname(__file__), "certificatechain.pem")
Example #10
Source File: spawner.py From jupyterhub-kubernetes_spawner with Apache License 2.0 | 6 votes |
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
Example #11
Source File: request.py From BillCipher with GNU General Public License v3.0 | 6 votes |
def send(self,method,url,params=None,data=None,headers=None): if headers is None: headers={} headers['User-Agent'] = Request.agent try: session = requests.Session() req = urllib3.disable_warnings( urllib3.exceptions.InsecureRequestWarning ) req = requests.request( method = method.upper(), url = url, params = params, data = data, allow_redirects = True, verify = False ) return req except Exception as e: exit(warn('Failed to establish a new connection'))
Example #12
Source File: session.py From onegram with MIT License | 6 votes |
def enter_contexts(self): self._requests = yield requests.Session() proxies = self.settings.get('PROXIES') if proxies: self._requests.proxies = proxies verify_ssl = self.settings.get('VERIFY_SSL', True) self._requests.verify = verify_ssl if not verify_ssl: urllib3.disable_warnings(InsecureRequestWarning) self._requests.headers.update(DEFAULT_HEADERS) user_agent = self.settings.get('USER_AGENT') if user_agent is not None: self._requests.headers['User-Agent'] = user_agent else: self._requests.headers.pop('User-Agent', None) response = self._requests.get(URLS['start']) response.raise_for_status() self._update_csrftoken(response) self._update_rhx_gis(response) self.rate_limiter = RateLimiter(self)
Example #13
Source File: test_bad_urllib3_module_attribute_use.py From dlint with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_bad_urllib3_module_attribute_usage(self): python_node = self.get_ast_node( """ import urllib3 urllib3.disable_warnings() """ ) linter = dlint.linters.BadUrllib3ModuleAttributeUseLinter() linter.visit(python_node) result = linter.get_results() expected = [ dlint.linters.base.Flake8Result( lineno=3, col_offset=0, message=dlint.linters.BadUrllib3ModuleAttributeUseLinter._error_tmpl ), ] assert result == expected
Example #14
Source File: dz-ml-rce.py From POC-EXP with GNU General Public License v3.0 | 6 votes |
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'
Example #15
Source File: request.py From Infoga with GNU General Public License v3.0 | 6 votes |
def send(self,method,url,params=None,data=None,headers=None): if headers is None: headers={} headers['User-Agent'] = Request.agent try: session = requests.Session() req = urllib3.disable_warnings( urllib3.exceptions.InsecureRequestWarning ) req = requests.request( method = method.upper(), url = url, params = params, data = data, allow_redirects = True, verify = False ) return req except Exception as e: exit(warn('Failed to establish a new connection'))
Example #16
Source File: Request.py From SharPyShell with GNU General Public License v3.0 | 6 votes |
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))
Example #17
Source File: turing.py From ExpressBot with GNU General Public License v2.0 | 6 votes |
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')
Example #18
Source File: utils.py From grimoirelab-elk with GNU General Public License v3.0 | 6 votes |
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
Example #19
Source File: conftest.py From aws-media-insights-engine with Apache License 2.0 | 6 votes |
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
Example #20
Source File: conftest.py From aws-media-insights-engine with Apache License 2.0 | 6 votes |
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
Example #21
Source File: conftest.py From aws-media-insights-engine with Apache License 2.0 | 6 votes |
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
Example #22
Source File: tntfuzzer.py From TnT-Fuzzer with MIT License | 6 votes |
def __init__(self, url, iterations, headers, log_unexpected_errors_only, max_string_length, use_string_pattern, ignore_tls=False, host=None, basepath=None, ignored_paths=[]): self.url = url self.iterations = iterations self.headers = headers self.log_unexpected_errors_only = log_unexpected_errors_only self.max_string_length = max_string_length self.use_string_pattern = use_string_pattern self.ignore_tls = ignore_tls self.host = host self.basepath = basepath self.ignored_paths = ignored_paths if self.ignore_tls: # removes warnings for insecure connections urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
Example #23
Source File: openPMD.py From postpic with GNU General Public License v3.0 | 6 votes |
def download(url, file): import urllib3 import shutil import os if os.path.isfile(file): return True try: urllib3.disable_warnings() http = urllib3.PoolManager() print('downloading {:} ...'.format(file)) with http.request('GET', url, preload_content=False) as r, open(file, 'wb') as out_file: shutil.copyfileobj(r, out_file) success = True except urllib3.exceptions.MaxRetryError: success = False return success
Example #24
Source File: kspace-test-2d.py From postpic with GNU General Public License v3.0 | 6 votes |
def download(url, file): import urllib3 import shutil import os if os.path.isfile(file): return True try: urllib3.disable_warnings() http = urllib3.PoolManager() print('downloading {:} ...'.format(file)) with http.request('GET', url, preload_content=False) as r, open(file, 'wb') as out_file: shutil.copyfileobj(r, out_file) success = True except urllib3.exceptions.MaxRetryError: success = False return success
Example #25
Source File: http.py From catcher with Apache License 2.0 | 6 votes |
def __init__(self, **kwargs) -> None: super().__init__(**kwargs) method = Step.filter_predefined_keys(kwargs) # get/post/put... self.method = method.lower() conf = kwargs[method] self.url = conf['url'] self.headers = conf.get('headers', {}) self.verify = conf.get('verify', True) self._should_fail = conf.get('should_fail', False) if not self.verify: import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) self.code = conf.get('response_code', 200) self.body = conf.get('body') self.file = conf.get('body_from_file') self.files = conf.get('files') self.session = conf.get('session', 'default') self.fix_cookies = conf.get('fix_cookies', True) self.timeout = conf.get('timeout')
Example #26
Source File: session.py From gs-quant with Apache License 2.0 | 6 votes |
def __init__(self, environment, client_id, client_secret, scopes, api_version=API_VERSION, application=DEFAULT_APPLICATION, http_adapter=None): if environment not in (Environment.PROD.name, Environment.QA.name, Environment.DEV.name): env_config = self._config_for_environment(Environment.DEV.name) url = environment else: env_config = self._config_for_environment(environment) url = env_config['AppDomain'] super().__init__(url, api_version=api_version, application=application, http_adapter=http_adapter) self.auth_url = env_config['AuthURL'] self.client_id = client_id self.client_secret = client_secret self.scopes = scopes if environment == Environment.DEV.name or url != env_config['AppDomain']: import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) self.verify = False
Example #27
Source File: client.py From opentaps_seas with GNU Lesser General Public License v3.0 | 6 votes |
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
Example #28
Source File: Requests.py From Vxscan with Apache License 2.0 | 6 votes |
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
Example #29
Source File: test_spark.py From integrations-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_ssl_no_verify(): # Disable ssl warning for self signed cert/no verify urllib3.disable_warnings() run_ssl_server() c = SparkCheck('spark', {}, [SSL_NO_VERIFY_CONFIG]) c.check(SSL_NO_VERIFY_CONFIG)
Example #30
Source File: hosted_neptune_backend.py From neptune-client with Apache License 2.0 | 5 votes |
def __init__(self, api_token=None, proxies=None): if api_token == ANONYMOUS: api_token = ANONYMOUS_API_TOKEN # This is not a top-level import because of circular dependencies from neptune import __version__ self.client_lib_version = __version__ self.credentials = Credentials(api_token) ssl_verify = True if os.getenv("NEPTUNE_ALLOW_SELF_SIGNED_CERTIFICATE"): urllib3.disable_warnings() ssl_verify = False self._http_client = RequestsClient(ssl_verify=ssl_verify) update_session_proxies(self._http_client.session, proxies) config_api_url = self.credentials.api_url_opt or self.credentials.token_origin_address self._verify_host_resolution(config_api_url, self.credentials.token_origin_address) backend_client = self._get_swagger_client('{}/api/backend/swagger.json'.format(config_api_url)) self._client_config = self._create_client_config(self.credentials.api_token, backend_client) self._verify_version() self._set_swagger_clients(self._client_config, config_api_url, backend_client) self.authenticator = self._create_authenticator(self.credentials.api_token, ssl_verify, proxies) self._http_client.authenticator = self.authenticator user_agent = 'neptune-client/{lib_version} ({system}, python {python_version})'.format( lib_version=self.client_lib_version, system=platform.platform(), python_version=platform.python_version()) self._http_client.session.headers.update({'User-Agent': user_agent})