How to use the urllib3.disable_warnings function in urllib3

To help you get started, we’ve selected a few urllib3 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 pwm / rig-stats / rig_stats.py View on Github external
def main():
    args = parse_args()
    pool_collector = None

    urllib3.disable_warnings()
    nvml.nvmlInit()
    atexit.register(nvml.nvmlShutdown)
    REGISTRY.register(NvidiaCollector())
    if args['pool'] is not None:
        pool_collector = pool_collectors()[args['pool'].lower()](args['pool_api_host'], args['pool_api_miner'])
        pool_collector.query_pool()
        REGISTRY.register(pool_collector)
    if args['miner'] is not None:
        REGISTRY.register(miner_collectors()[args['miner'].lower()](args['miner_api_host'], args['miner_api_port']))

    print('Starting exporter...')
    try:
        start_http_server(args['port'])
        while True:
            time.sleep(60)  # 1 query per minute so we don't reach API request limits
            if pool_collector is not None:
github forkd / netbox-scanner / netbox-scanner.py View on Github external
argsp = subparsers.add_parser('netxms', help='NetXMS module')
argsp = subparsers.add_parser('prime', help='Cisco Prime module')
args = parser.parse_args()

logfile = '{}/netbox-scanner-{}.log'.format(
    netbox['logs'],
    datetime.now().isoformat()
)
logging.basicConfig(
    filename=logfile, 
    level=logging.INFO, 
    format='%(asctime)s\tnetbox-scanner\t%(levelname)s\t%(message)s'
)
logging.getLogger().addHandler(logging.StreamHandler())

disable_warnings(InsecureRequestWarning)


def cmd_nmap(s):  # nmap handler
    h = Nmap(nmap['path'], nmap['unknown'])
    h.run()
    s.sync(h.hosts)

def cmd_netxms(s):  # netxms handler
    h = NetXMS(
        netxms['address'],
        netxms['username'],
        netxms['password'],
        netxms.getboolean('tls_verify'),
        netxms['unknown']
    )
    h.run()
github kaisero / fireREST / fireREST / __init__.py View on Github external
timeout=defaults.API_REQUEST_TIMEOUT,
    ):
        '''
        Initialize api client object (make sure to use a dedicated api user!)
        :param hostname: ip address or dns name of fmc
        :param username: fmc username
        :param password: fmc password
        :param protocol: protocol used to access fmc rest api
        :param verify_cert: check https certificate for validity
        :param cache: enable result caching for get operations
        :param logger: optional logger instance
        :param domain: name of the domain to access
        :param timeout: timeout value for http requests
        '''
        if not verify_cert:
            urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
        self.headers = {
            'Content-Type': defaults.API_CONTENT_TYPE,
            'Accept': defaults.API_CONTENT_TYPE,
            'User-Agent': defaults.API_USER_AGENT,
        }
        self.cache = cache
        self.cred = HTTPBasicAuth(username, password)
        self.hostname = hostname
        self.protocol = protocol
        self.refresh_counter = defaults.API_REFRESH_COUNTER_INIT
        self.session = requests.Session()
        self.timeout = timeout
        self.verify_cert = verify_cert
        self._login()
        self.domain_name = domain
        self.domain = self.get_domain_id_by_name(domain)
github dcos / dcos-e2e / src / dcos_e2e_cli / common / wait.py View on Github external
doctor_command_name: str,
) -> None:
    """
    Wait for DC/OS to start.

    Args:
        cluster: The cluster to wait for.
        superuser_username: If the cluster is a DC/OS Enterprise cluster, use
            this username to wait for DC/OS.
        superuser_password: If the cluster is a DC/OS Enterprise cluster, use
            this password to wait for DC/OS.
        http_checks: Whether or not to wait for checks which require an HTTP
            connection to the cluster.
        doctor_command_name: A ``doctor`` command to advise a user to use.
    """
    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
    message = (
        'A cluster may take some time to be ready.\n'
        'The amount of time it takes to start a cluster depends on a variety '
        'of factors.\n'
        'If you are concerned that this is hanging, try '
        '"{doctor_command_name}" to diagnose common issues.'
    ).format(doctor_command_name=doctor_command_name)
    click.echo(message)

    no_login_message = (
        'If you cancel this command while it is running, '
        'you may not be able to log in. '
        'To resolve that, run this command again.'
    )

    spinner = Halo(enabled=sys.stdout.isatty())
github opnsense / core / src / opnsense / scripts / filter / update_tables.py View on Github external
--------------------------------------------------------------------------------------
    update aliases
"""

import os
import sys
import argparse
import json
import urllib3
import xml.etree.cElementTree as ET
import syslog
import subprocess
import glob
from lib.alias import Alias
import lib.geoip as geoip
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)


class AliasParser(object):
    """ Alias Parser class, encapsulates all aliases
    """
    def __init__(self, source_tree):
        self._source_tree = source_tree
        self._aliases = dict()

    def read(self):
        """ read aliases
            :return: None
        """
        self._aliases = dict()
        alias_parameters = dict()
        alias_parameters['known_aliases'] = [x.text for x in self._source_tree.iterfind('table/name')]
github dustcloud / smartmeshsdk / vmanager_apps / VMgr_BlinkData.py View on Github external
import base64
import certifi

# generic SmartMeshSDK imports
from SmartMeshSDK                      import sdk_version
from SmartMeshSDK.protocols.blink      import blink
# VManager-specific imports
from VManagerSDK.vmanager              import Configuration
from VManagerSDK.vmgrapi               import VManagerApi
from VManagerSDK.vmanager.rest         import ApiException

#============================ defines =========================================

DFLT_VMGR_HOST     = "127.0.0.1"

urllib3.disable_warnings() # disable warnings that show up about self-signed certificates

#============================ helpers =========================================

def process_data(data_notif):
    payload = base64.b64decode(data_notif.payload)
    try:
        (data,neighbors) = blink.decode_blink(payload)
        if data:
            print 'Blink packet received from {0}'.format(data_notif.mac_address)
            for neighbor_id, rssi in neighbors:
                print '    --> Neighbor ID = {0},  RSSI = {1}'.format(neighbor_id, rssi)
            if not neighbors:
                print '    --> Neighbors = n/a'            
            print '    --> Data Sent = {0}\n\n'.format(data.encode("hex"))
    except: 
        # handle non-blink data
github nzlosh / err-stackstorm / lib / st2pluginauth.py View on Github external
def __init__(self, st2config):
        self.cfg = st2config
        self.verify_cert = st2config.verify_cert
        if self.verify_cert is False:
            urllib3.disable_warnings()

        self.api_key = st2config.api_auth.get('key')
        self.token = st2config.api_auth.get('token')
        tmp = st2config.api_auth.get('user')
        self.username = None
        self.password = None

        if tmp:
            self.username = tmp.get('name')
            self.password = tmp.get('password')
github nstrelow / ha_philips_android_tv / philips_android_tv / media_player.py View on Github external
from base64 import b64encode,b64decode
from datetime import timedelta, datetime
from homeassistant.components.media_player import (MediaPlayerDevice, PLATFORM_SCHEMA)
from homeassistant.components.media_player.const import (SUPPORT_STOP, SUPPORT_PLAY, SUPPORT_NEXT_TRACK, SUPPORT_PAUSE,
                                                   SUPPORT_PREVIOUS_TRACK, SUPPORT_VOLUME_SET, SUPPORT_TURN_OFF, SUPPORT_TURN_ON,
                                                   SUPPORT_VOLUME_MUTE, SUPPORT_VOLUME_STEP, SUPPORT_SELECT_SOURCE)
from homeassistant.const import (CONF_HOST, CONF_MAC, CONF_NAME, CONF_USERNAME, CONF_PASSWORD,
                                 STATE_OFF, STATE_ON, STATE_IDLE, STATE_UNKNOWN, STATE_PLAYING, STATE_PAUSED)
from homeassistant.util import Throttle
from requests.auth import HTTPDigestAuth
from requests.adapters import HTTPAdapter

# Workaround to suppress warnings about SSL certificates in Home Assistant log
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

_LOGGER = logging.getLogger(__name__)

CONF_FAV_ONLY = 'favorite_channels_only'

MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=5)

SUPPORT_PHILIPS_2016 = SUPPORT_STOP | SUPPORT_TURN_OFF | SUPPORT_TURN_ON | SUPPORT_VOLUME_STEP | \
                       SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET |SUPPORT_NEXT_TRACK | \
                       SUPPORT_PAUSE | SUPPORT_PREVIOUS_TRACK | SUPPORT_PLAY | SUPPORT_SELECT_SOURCE

DEFAULT_DEVICE = 'default'
DEFAULT_HOST = '127.0.0.1'
DEFAULT_MAC = 'aa:aa:aa:aa:aa:aa'
DEFAULT_USER = 'user'
DEFAULT_PASS = 'pass'
github Python3WebSpider / DouYin / douyin / utils / __init__.py View on Github external
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

from douyin.utils.fetch import fetch
github ENCODE-DCC / encoded / src / encoded / peak_indexer.py View on Github external
def index_bed(href, request, context, assembly):

    urllib3.disable_warnings()
    http = urllib3.PoolManager(timeout=3.0)
    dlreq = http.request('GET', href )

    if not dlreq or dlreq.status != 200:
        log.warn("File (%s or %s) not found" % (context.get('href',"No href"), context.get('submitted_file_name', 'No submitted file name')))
        return

    comp = io.BytesIO()
    comp.write(dlreq.data)
    comp.seek(0)
    dlreq.release_conn()

    file_data = dict()
    es = request.registry.get(SNP_SEARCH_ES, None)

    with gzip.open(comp, mode='rt') as file: