Python requests.packages.urllib3.exceptions.InsecureRequestWarning() Examples

The following are 30 code examples of requests.packages.urllib3.exceptions.InsecureRequestWarning(). 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 requests.packages.urllib3.exceptions , or try the search function .
Example #1
Source File: wio.py    From wio-cli with MIT License 7 votes vote down vote up
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) 
Example #2
Source File: http.py    From omnibus with MIT License 6 votes vote down vote up
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) 
Example #3
Source File: __init__.py    From freesms with MIT License 6 votes vote down vote up
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) 
Example #4
Source File: http.py    From omnibus with MIT License 6 votes vote down vote up
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) 
Example #5
Source File: get-power-state.py    From sysadmin-tools with Apache License 2.0 6 votes vote down vote up
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) 
Example #6
Source File: turn-power-off.py    From sysadmin-tools with Apache License 2.0 6 votes vote down vote up
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) 
Example #7
Source File: turn-power-on.py    From sysadmin-tools with Apache License 2.0 6 votes vote down vote up
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) 
Example #8
Source File: Update.py    From drupwn with GNU General Public License v3.0 6 votes vote down vote up
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 
Example #9
Source File: miniprobe.py    From PythonMiniProbe with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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 
Example #10
Source File: common.py    From iot-python with Eclipse Public License 1.0 6 votes vote down vote up
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) 
Example #11
Source File: requestmaker.py    From python-taiga with MIT License 6 votes vote down vote up
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) 
Example #12
Source File: 04_solarwinds_delete_node.py    From cloudbolt-forge with Apache License 2.0 5 votes vote down vote up
def run(job=None, *args, **kwargs):
    # Disable SSL errors
    verify = False
    if not verify:
        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

    # Get SolarWinds ConnectionInfo
    solarwinds = ConnectionInfo.objects.get(name='SolarWinds')
    swis = SwisClient(solarwinds.ip, solarwinds.username, solarwinds.password)
    if not solarwinds:
        return "FAILURE", "", "Missing required SolarWinds connection info. (Admin -> Connection Info -> New Connection Info)"

    # Get Server Info
    server = job.server_set.first()

    # Find the Uri you want to delete based on a SWQL query
    results = swis.query("select ipaddress, caption, uri from orion.nodes where ipaddress = '{}'".format(server.ip))

    # Use as needed
    if len(results['results']) > 1:
        print('Refine your search. Found more than one node matching that criteria.')
    elif len(results['results']) == 1:
        print("Deleting {}".format(results['results'][0]['ipaddress']))
        response = swis.delete(results['results'][0]['uri'])
        print("Done")
    else:
        print("Nothing to delete from SolarWinds")

    return "","","" 
Example #13
Source File: isamappliance.py    From ibmsecurity with Apache License 2.0 5 votes vote down vote up
def _suppress_ssl_warning(self):
        # Disable https warning because of non-standard certs on appliance
        try:
            self.logger.debug("Suppressing SSL Warnings.")
            requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
        except AttributeError:
            self.logger.warning("load requests.packages.urllib3.disable_warnings() failed") 
Example #14
Source File: isdsappliance.py    From ibmsecurity with Apache License 2.0 5 votes vote down vote up
def _suppress_ssl_warning(self):
        # Disable https warning because of non-standard certs on appliance
        try:
            self.logger.debug("Suppressing SSL Warnings.")
            requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
        except AttributeError:
            self.logger.warning("load requests.packages.urllib3.disable_warnings() failed") 
Example #15
Source File: simplewriter.py    From plugin.video.brplay with GNU General Public License v3.0 5 votes vote down vote up
def init(self, out_stream, url, proxy=None, stopEvent=None, maxbitrate=0):
        try:
            from requests.packages.urllib3.exceptions import InsecureRequestWarning
            requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
            self.session = requests.Session()
            self.session.cookies = self.cookieJar
            self.clientHeader = None
            self.proxy = proxy

            if self.proxy and len(self.proxy) == 0:
                self.proxy=None

            self.use_proxy = False

            if stopEvent: stopEvent.clear()

            self.g_stopEvent=stopEvent
            self.maxbitrate=maxbitrate

            if '|' in url:
                sp = url.split('|')
                url = sp[0]
                self.clientHeader = sp[1]
                self.log(self.clientHeader)
                self.clientHeader= urlparse.parse_qsl(self.clientHeader)
                self.log('header received now url and headers are %s | %s' % (url, self.clientHeader))

            self.url=url

            return True
        except:
            traceback.print_exc()

        return False 
Example #16
Source File: 00_solarwinds_validate_unique_node.py    From cloudbolt-forge with Apache License 2.0 5 votes vote down vote up
def run(job=None, *args, **kwargs):
    # Disable SSL errors
    verify = False
    if not verify:
        from requests.packages.urllib3.exceptions import InsecureRequestWarning 
        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

    # Get SolarWinds ConnectionInfo
    solarwinds = ConnectionInfo.objects.get(name='SolarWinds')
    swis = SwisClient(solarwinds.ip, solarwinds.username, solarwinds.password)
    if not solarwinds:
        return "FAILURE", "", "Missing required SolarWinds connection info. (Admin -> Connection Info -> New Connection Info)"

    # Get Server Info
    server = job.server_set.first()

    # Query Solarwinds for the FQDN & IP
    job.set_progress("Checking if node '{}' is already in SolarWinds".format(server.hostname))
    hostname_results = swis.query("select n.ipaddress, n.nodename from orion.nodes n where nodename = '{}'".format(server.hostname))

    if len(next(iter(hostname_results.values()))) == 0:
        set_progress("'{}' not found in Solarwinds.".format(server.hostname))
    else:
        return 'FAILURE', '', "Found node '{}' in Solarwinds.".format(server.hostname)

    return "", "", "" 
Example #17
Source File: api.py    From PBinCLI with MIT License 5 votes vote down vote up
def _config_requests(settings=None):
    if settings['proxy']:
        proxy = {settings['proxy'].split('://')[0]: settings['proxy']}
    else:
        proxy = {}

    if settings['no_insecure_warning']:
        from requests.packages.urllib3.exceptions import InsecureRequestWarning
        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

    session = requests.Session()
    session.verify = not settings['no_check_certificate']

    return session, proxy 
Example #18
Source File: views.py    From cloudbolt-forge with Apache License 2.0 5 votes vote down vote up
def get_context_data(node_name, sam_server, username, password):
    """Put together the context data"""

    # disable SSL warnings and connect to SolarWinds
    disable_warnings(category=InsecureRequestWarning)
    swis = SwisClient(hostname=sam_server, username=username, password=password)

    # Get node id
    node_id = get_node_id(swis=swis, node_name=node_name)

    # Put together context
    context = {}
    context['server_url'] = get_server_url(swis=swis)
    context['node_details'] = get_node_details(swis=swis, node_id=node_id)
    context['availability'] = get_availability(swis=swis, node_id=node_id)
    context['applications'] = get_applications(swis=swis, node_id=node_id)
    context['volumes'] = get_volumes(swis=swis, node_id=node_id)
    context['active_alerts'] = get_active_alerts(swis=swis, node_id=node_id)
    context['last_25_events'] = get_last_25_events(swis=swis, node_id=node_id)

    # Return the context
    return context

# </get_context_data>

# <get_server_url> 
Example #19
Source File: hlsdownloader.py    From plugin.video.brplay with GNU General Public License v3.0 5 votes vote down vote up
def init(self, out_stream, url, proxy=None, g_stop_event=None, maxbitrate=0):
        try:
            from requests.packages.urllib3.exceptions import InsecureRequestWarning
            requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
            self.session = requests.Session()
            self.session.cookies = cookielib.LWPCookieJar()
            self.init_done = False
            self.init_url = url
            self.clientHeader = None
            self.proxy = proxy
            self.use_proxy = False

            if self.proxy and len(self.proxy) == 0:
                self.proxy = None

            self.out_stream = out_stream

            if g_stop_event: g_stop_event.clear()

            self.g_stopEvent = g_stop_event
            self.maxbitrate = maxbitrate

            if '|' in url:
                sp = url.split('|')
                url = sp[0]
                self.clientHeader = sp[1]
                self.log(self.clientHeader)
                self.clientHeader = urlparse.parse_qsl(self.clientHeader)
                self.log('header received now url and headers are %s | %s' % (url, self.clientHeader))

            self.url = url

            return True
        except:
            traceback.print_exc()

        return False 
Example #20
Source File: connection.py    From tfs with MIT License 5 votes vote down vote up
def __init__(self, base_url, project, user, password, pat, verify=False, timeout=None, auth_type=None):
        if not base_url.endswith('/'):
            base_url += '/'

        collection, project = self.get_collection_and_project(project)
        self.collection = collection
        self.project = project
        # Remove part after / in project-name, like DefaultCollection/MyProject => DefaultCollection
        # API responce only in Project, without subproject
        self._url = base_url + '%s/_apis/' % collection
        if project:
            self._url_prj = base_url + '%s/%s/_apis/' % (collection, project)
        else:
            self._url_prj = self._url

        self.http_session = requests.Session()
        if pat is not None:
            pat = ":" + pat
            pat_base64 = b'Basic ' + base64.b64encode(pat.encode("utf8"))
            self.http_session.headers.update({'Authorization': pat_base64})
        else:
            auth = auth_type() if user is None and password is None else auth_type(user, password)
            self.http_session.auth = auth

        self.api_version = None
        self.timeout = timeout
        self._verify = verify
        if not self._verify:
            from requests.packages.urllib3.exceptions import InsecureRequestWarning
            requests.packages.urllib3.disable_warnings(InsecureRequestWarning) 
Example #21
Source File: IgnoreWarnings.py    From AmazonRobot with MIT License 5 votes vote down vote up
def ignore_warnings():
    requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
    requests.packages.urllib3.disable_warnings(SubjectAltNameWarning)
    requests.packages.urllib3.disable_warnings(InsecurePlatformWarning)
    requests.packages.urllib3.disable_warnings(SNIMissingWarning) 
Example #22
Source File: connection.py    From loom with GNU Affero General Public License v3.0 5 votes vote down vote up
def disable_insecure_request_warning():
    """Suppress warning about untrusted SSL certificate."""
    import requests
    from requests.packages.urllib3.exceptions import InsecureRequestWarning
    requests.packages.urllib3.disable_warnings(InsecureRequestWarning) 
Example #23
Source File: artist.py    From Saavn-Downloader with MIT License 5 votes vote down vote up
def __init__(self, proxies, headers, args, url=None):
        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
        self.proxies = proxies
        self.headers = headers
        self.args = args
        self.artistID = None
        self.artist_name = None
        self.artist_json = []
        self.album_IDs_artist = []
        self.url = url 
Example #24
Source File: ForemanAPIClient.py    From katprep with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, log_level, hostname,
                 username, password, verify=True, prefix=""):
        """
        Constructor, creating the class. It requires specifying a
        hostname, username and password to access the API. After
        initialization, a connected is established.

        :param log_level: log level
        :type log_level: logging
        :param hostname: Foreman host
        :type hostname: str
        :param username: API username
        :type username: str
        :param password: corresponding password
        :type password: str
        :param verify: force SSL verification
        :type verify: bool
        :param prefix: API prefix (e.g. /katello)
        :type prefix: str
        """
        #set logging
        self.LOGGER.setLevel(log_level)
        #disable SSL warning outputs
        requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
        #set connection information
        self.HOSTNAME = hostname
        self.USERNAME = username
        self.PASSWORD = password
        self.VERIFY = verify
        self.URL = "https://{0}{1}/api/v2".format(self.HOSTNAME, prefix)
        #start session and check API version if Foreman API
        self.__connect()
        if prefix == "":
            self.validate_api_support() 
Example #25
Source File: crlf.py    From Vaile with GNU General Public License v3.0 5 votes vote down vote up
def getHeaders0x00(web0x00, headers):

    try:
        requests = session()
        wrn.packages.urllib3.disable_warnings(InsecureRequestWarning)
        print(GR+' [*] Requesting headers...')
        r = requests.get(web0x00, headers=headers, timeout=7, verify=False)
        head = r.headers
        return head
    except Exception as e:
        print(R+' [-] Unexpected Exception Encountered!')
        print(R+' [-] Exception : '+str(e)) 
Example #26
Source File: backup_vm_v1.2.py    From VirtBKP with GNU General Public License v3.0 5 votes vote down vote up
def detach_disk(bkpid,diskid):
 urldelete = url+"/vms/"+bkpid+"/diskattachments/"+diskid
 requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
 requests.delete(urldelete, verify=False, auth=(user,password))

# Funcion para obtener el nombre de dispositivo de disco virtual
# Function to get device name of a virtual disk 
Example #27
Source File: backup_vm_v1.2.py    From VirtBKP with GNU General Public License v3.0 5 votes vote down vote up
def attach_disk(bkpid,diskid,snapid):
 xmlattach =  "<disk id=\""+diskid+"\"><snapshot id=\""+snapid+"\"/> <active>true</active></disk>"
 urlattach = url+"/v3/vms/"+bkpid+"/disks/"
 headers = {'Content-Type': 'application/xml', 'Accept': 'application/xml'}
 requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
 resp_attach = requests.post(urlattach, data=xmlattach, headers=headers, verify=False, auth=(user,password))

# Funcion para desactivar disco virtual
# Function to deactivate virtual disk 
Example #28
Source File: backup_vm_last.py    From VirtBKP with GNU General Public License v3.0 5 votes vote down vote up
def attach_disk(self,bkpid,diskid,snapid):
  xmlattach =  "<disk id=\""+diskid+"\"><snapshot id=\""+snapid+"\"/> <active>true</active></disk>"
  urlattach = self.url+"/v3/vms/"+bkpid+"/disks/"
  headers = {'Content-Type': 'application/xml', 'Accept': 'application/xml'}
  requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
  resp_attach = requests.post(urlattach, data=xmlattach, headers=headers, verify=False, auth=(self.user,self.password))

# Funcion para desactivar disco virtual
# Function to deactivate virtual disk 
Example #29
Source File: backup_vm_v1.7.py    From VirtBKP with GNU General Public License v3.0 5 votes vote down vote up
def attach_disk(self,bkpid,diskid,snapid):
  xmlattach =  "<disk id=\""+diskid+"\"><snapshot id=\""+snapid+"\"/> <active>true</active></disk>"
  urlattach = self.url+"/v3/vms/"+bkpid+"/disks/"
  headers = {'Content-Type': 'application/xml', 'Accept': 'application/xml'}
  requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
  resp_attach = requests.post(urlattach, data=xmlattach, headers=headers, verify=False, auth=(self.user,self.password))

# Funcion para desactivar disco virtual
# Function to deactivate virtual disk 
Example #30
Source File: backup_vm_v1.3.py    From VirtBKP with GNU General Public License v3.0 5 votes vote down vote up
def detach_disk(bkpid,diskid):
 urldelete = url+"/vms/"+bkpid+"/diskattachments/"+diskid
 requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
 requests.delete(urldelete, verify=False, auth=(user,password))

# Funcion para obtener el nombre de dispositivo de disco virtual
# Function to get device name of a virtual disk