How to use the requests.packages.urllib3.disable_warnings function in requests

To help you get started, we’ve selected a few requests examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wazo-platform / wazo-calld / integration_tests / suite / base.py View on Github external
import requests
import time
import yaml

from hamcrest import assert_that, equal_to
from kombu import Connection
from kombu import Consumer
from kombu import Exchange
from kombu import Queue
from kombu.exceptions import TimeoutError
from requests.packages import urllib3
from xivo_test_helpers.asset_launching_test_case import AssetLaunchingTestCase

logger = logging.getLogger(__name__)

urllib3.disable_warnings()

ASSET_ROOT = os.path.join(os.path.dirname(__file__), '..', 'assets')
INVALID_ACL_TOKEN = 'invalid-acl-token'
VALID_TOKEN = 'valid-token'
BUS_EXCHANGE_NAME = 'xivo'
BUS_EXCHANGE_TYPE = 'topic'
BUS_URL = 'amqp://guest:guest@localhost:5672//'
BUS_QUEUE_NAME = 'integration'
XIVO_UUID = yaml.load(open(os.path.join(ASSET_ROOT, '_common', 'etc', 'xivo-ctid-ng', 'conf.d', 'uuid.yml'), 'r'))['uuid']
STASIS_APP_NAME = 'callcontrol'


class IntegrationTest(AssetLaunchingTestCase):

    assets_root = ASSET_ROOT
    service = 'ctid-ng'
github F5Networks / f5-openstack-agent / test / functional / neutronless / disconnected_service / test_disconnected_service_creation.py View on Github external
from distutils.version import StrictVersion
from f5.bigip import ManagementRoot
from f5.utils.testutils.registrytools import register_device
from f5_openstack_agent.lbaasv2.drivers.bigip.icontrol_driver import \
    iControlDriver
import json
import logging
import mock
from mock import call
import os
from os.path import dirname as osd
import pytest
import requests
import time

requests.packages.urllib3.disable_warnings()

LOG = logging.getLogger(__name__)

oslo_config_filename =\
    os.path.join(osd(os.path.abspath(__file__)), 'oslo_confs.json')
# Toggle feature on/off configurations
OSLO_CONFIGS = json.load(open(oslo_config_filename))
FEATURE_ON = OSLO_CONFIGS["feature_on"]
FEATURE_OFF = OSLO_CONFIGS["feature_off"]
FEATURE_OFF_GRM = OSLO_CONFIGS["feature_off_grm"]
FEATURE_OFF_COMMON_NET = OSLO_CONFIGS["feature_off_common_net"]
FEATURE_ON['icontrol_hostname'] = pytest.symbols.bigip_mgmt_ip_public
FEATURE_OFF['icontrol_hostname'] = pytest.symbols.bigip_mgmt_ip_public
FEATURE_OFF_GRM['icontrol_hostname'] = pytest.symbols.bigip_mgmt_ip_public
FEATURE_OFF_COMMON_NET['icontrol_hostname'] = \
    pytest.symbols.bigip_mgmt_ip_public
github psss / did / did / plugins / confluence.py View on Github external
def session(self):
        """ Initialize the session """
        if self._session is None:
            self._session = requests.Session()
            log.debug("Connecting to {0}".format(self.auth_url))
            # Disable SSL warning when ssl_verify is False
            if not self.ssl_verify:
                requests.packages.urllib3.disable_warnings(
                    InsecureRequestWarning)
            if self.auth_type == "basic":
                basic_auth = (self.auth_username, self.auth_password)
                response = self._session.get(
                    self.auth_url, auth=basic_auth, verify=self.ssl_verify)
            else:
                gssapi_auth = HTTPSPNEGOAuth(mutual_authentication=DISABLED)
                response = self._session.get(
                    self.auth_url, auth=gssapi_auth, verify=self.ssl_verify)
            try:
                response.raise_for_status()
            except requests.exceptions.HTTPError as error:
                log.error(error)
                raise ReportError(
                    "Confluence authentication failed. Try kinit.")
        return self._session
github mazen160 / bfac / bfac / bfac.py View on Github external
def disable_ssl_errors():
		#Disabling unwanted SSL errors
		try:
			requests.packages.urllib3.disable_warnings()
		except AttributeError:
			pass #Commented out to avoid the annoyance of showing the message in every execution of the script. #print(tcolor.red+'[!]requests.packages.urllib3.disable_warnings() does not seem to be working. Bogus errors may be shown during the usage of the tool.'+tcolor.endcolor)
github demisto / content / Integrations / ServiceNow / ServiceNow.py View on Github external
import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *
import re
import requests
import json
from datetime import datetime
import shutil

# disable insecure warnings
requests.packages.urllib3.disable_warnings()

if not demisto.params().get('proxy', False):
    del os.environ['HTTP_PROXY']
    del os.environ['HTTPS_PROXY']
    del os.environ['http_proxy']
    del os.environ['https_proxy']


def get_server_url():
    url = demisto.params()['url']
    url = re.sub('/[\/]+$/', '', url)
    url = re.sub('\/$', '', url)
    return url


''' GLOBAL VARIABLES '''
github CiscoDevNet / devnet-express-code-samples / module09 / create_notification.py View on Github external
#!/usr/bin/env python
#
# Configure CMX notification
#
# darien@sdnessentials.com
#


import requests
from requests.auth import HTTPBasicAuth
import sys
requests.packages.urllib3.disable_warnings()

USERNAME = 'learning'
PASSWORD = 'learning'
URI = 'https://msesandbox.cisco.com:8081/api/config/v1/notification'
PAYLOAD = 'notification.json'


def main():
    """Simple main method to create a CMX notification."""
    try:
        f = open(PAYLOAD, 'r')
        data = f.read().replace('\n', '')
        # print(json.dumps(data))
        headers = {
            'content-type': "application/json",
            'accept': "application/json"
github bcbio / bcbio-nextgen / bcbio / install.py View on Github external
def _install_kraken_db(datadir, args):
    """Install kraken minimal DB in genome folder.
    """
    import requests
    kraken = os.path.join(datadir, "genomes/kraken")
    url = "https://ccb.jhu.edu/software/kraken/dl/minikraken.tgz"
    compress = os.path.join(kraken, os.path.basename(url))
    base, ext = utils.splitext_plus(os.path.basename(url))
    db = os.path.join(kraken, base)
    tooldir = args.tooldir or get_defaults()["tooldir"]
    requests.packages.urllib3.disable_warnings()
    last_mod = urllib.request.urlopen(url).info().get('Last-Modified')
    last_mod = dateutil.parser.parse(last_mod).astimezone(dateutil.tz.tzutc())
    if os.path.exists(os.path.join(tooldir, "bin", "kraken")):
        if not os.path.exists(db):
            is_new_version = True
        else:
            cur_file = glob.glob(os.path.join(kraken, "minikraken_*"))[0]
            cur_version = datetime.datetime.utcfromtimestamp(os.path.getmtime(cur_file))
            is_new_version = last_mod.date() > cur_version.date()
            if is_new_version:
                shutil.move(cur_file, cur_file.replace('minikraken', 'old'))
        if not os.path.exists(kraken):
            utils.safe_makedir(kraken)
        if is_new_version:
            if not os.path.exists(compress):
                subprocess.check_call(["wget", "-O", compress, url, "--no-check-certificate"])
github ksator / junos_monitoring_with_healthbot / audit_healthbot_configuration.py View on Github external
r = requests.get(url + '/topic/' + topic + '/rule/' , auth=HTTPBasicAuth(authuser, authpwd), headers=headers, verify=False)
    pprint (r.json())
    return r.status_code

def get_rule(topic, rule):
    r = requests.get(url + '/topic/' + topic + '/rule/' + rule['rule-name'] + '/' , auth=HTTPBasicAuth(authuser, authpwd), headers=headers, verify=False)
    print '\n****************** rule '+ topic + '/' + rule['rule-name'] + ' ******************'
    pprint (r.json())
    return r.status_code


############################################################################################################################
# Below block is the REST calls to print healthbot configuration
############################################################################################################################

requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
my_variables_in_yaml=import_variables_from_file()
server = my_variables_in_yaml['server']
authuser = my_variables_in_yaml['authuser']
authpwd = my_variables_in_yaml['authpwd']
url = 'https://'+ server + ':8080/api/v1'
headers = { 'Accept' : 'application/json', 'Content-Type' : 'application/json' }

get_devices_name_in_running_configuration()

for item in my_variables_in_yaml['devices_list']:
    get_device_details_in_running_configuration(item)

for item in my_variables_in_yaml['tables_and_views']:
    get_tables_and_views(item)

get_notifications()
github ESSolutions / ESSArch_EPP / ESSArch_EPP / Storage / libs.py View on Github external
from essarch.libs import ESSArchSMError
from celery.result import AsyncResult
from django.core.exceptions import ObjectDoesNotExist
import requests
from rest_framework.renderers import JSONRenderer
from urlparse import urljoin
from api.serializers import ArchiveObjectPlusAICPlusStorageNestedReadSerializer
from retrying import retry
from api.serializers import IOQueueSerializer
from StorageMethodTape.tasks import ApplyPostRestError as tape_ApplyPostRestError
from StorageMethodDisk.tasks import ApplyPostRestError as disk_ApplyPostRestError

# Disable https insecure warnings
from requests.packages.urllib3.exceptions import InsecureRequestWarning, InsecurePlatformWarning
requests.packages.urllib3.disable_warnings(InsecurePlatformWarning)
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

import django
django.setup()

class DatabasePostRestException(Exception):
    """
    There was an ambiguous exception that occurred while handling your
    request.
    """
    def __init__(self, value):
        """
        Initialize DatabasePostRestException
        """
        self.value = value
        super(DatabasePostRestException, self).__init__(value)
github RedHatInsights / insights-core / insights / client / util.py View on Github external
def urllib3_disable_warnings():
    if 'requests' not in sys.modules:
        import requests
    else:
        requests = sys.modules['requests']

    # On latest Fedora, this is a symlink
    if hasattr(requests, 'packages'):
        requests.packages.urllib3.disable_warnings()  # pylint: disable=maybe-no-member
    else:
        # But with python-requests-2.4.3-1.el7.noarch, we need
        # to talk to urllib3 directly
        have_urllib3 = False
        try:
            if 'urllib3' not in sys.modules:
                import urllib3
                have_urllib3 = True
        except ImportError:
            pass
        if have_urllib3:
            # Except only call disable-warnings if it exists
            if hasattr(urllib3, 'disable_warnings'):
                urllib3.disable_warnings()