How to use the urllib3.exceptions.NewConnectionError 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 urllib3 / urllib3 / test / with_dummyserver / test_connectionpool.py View on Github external
def test_bad_connect(self):
        with HTTPConnectionPool("badhost.invalid", self.port) as pool:
            with pytest.raises(MaxRetryError) as e:
                pool.request("GET", "/", retries=5)
            assert type(e.value.reason) == NewConnectionError
github fga-eps-mds / 2019.1-ADA / ada / actions / set_issue_title.py View on Github external
def run(self, dispatcher, tracker, domain):
        try:
            message = tracker.latest_message.get('text')
            message = message.split(": ")
            issue_name = message[1]

            print("O titulo da Issue é: {issue_name}\n".format
                  (issue_name=issue_name))
        except ValueError:
            dispatcher.utter_message(
                "Estou com problemas para me conectar, me manda "
                "mais uma mensagem pra ver se dessa vez dá certo.")
        except NewConnectionError:
            dispatcher.utter_message(
                "Estou com problemas para me conectar, me manda "
                "mais uma mensagem pra ver se dessa vez dá certo.")

        else:
            return [SlotSet('issue_name', issue_name)]
github mgalloway22 / Prometheus-5Q / driver.py View on Github external
def kill_all_bindings():
    for binding in all_bindings:
        binding.terminate()
    url: str = BASE_URL + '/shadows'
    try:
        response: Response = get(url, headers=HEADERS)
    except (requests_exceptions.ConnectionError,
            url_exceptions.NewConnectionError):
        e: DasApplicationNotRunningError = (
            DasApplicationNotRunningError('Keyboard Driver'))
        e.elaborate()
        exit()
    for signal in loads(response.content):
        zone_id: str = signal['zoneId']
        delete(BASE_URL + '/pid/' + PID + '/zoneId/' + zone_id,
               headers=HEADERS)
github koroshiya / batoto-downloader-py / urllib3 / connection.py View on Github external
extra_kw['source_address'] = self.source_address

        if self.socket_options:
            extra_kw['socket_options'] = self.socket_options

        try:
            conn = connection.create_connection(
                (self.host, self.port), self.timeout, **extra_kw)

        except SocketTimeout as e:
            raise ConnectTimeoutError(
                self, "Connection to %s timed out. (connect timeout=%s)" %
                (self.host, self.timeout))

        except SocketError as e:
            raise NewConnectionError(
                self, "Failed to establish a new connection: %s" % e)

        return conn
github fga-eps-mds / 2019.1-ADA / ada / actions / set_pipeline.py View on Github external
dispatcher.utter_message(
                "Não consegui encontrar o seu pipeline no GitLab, "
                "por favor verifique se existe um e me manda novamente.")
        except IndexError:
            dispatcher.utter_message(
                "Não consegui encontrar o seu pipeline no GitLab, "
                "por favor verifique se existe um e me manda novamente.")
        except HTTPError:
            dispatcher.utter_message(
                "Não consegui achar um pipeline no seu repositório, "
                "tenta conferir se existe um e tente novamente.")
        except ValueError:
            dispatcher.utter_message(
                "Estou com problemas para me conectar, me manda "
                "mais uma mensagem pra ver se dessa vez dá certo.")
        except NewConnectionError:
            dispatcher.utter_message(
                "Estou com problemas para me conectar, me manda "
                "mais uma mensagem pra ver se dessa vez dá certo.")
github kylebebak / Requester / deps / requests / adapters.py View on Github external
preload_content=False,
                        decode_content=False
                    )
                except:
                    # If we hit any problems here, clean up the connection.
                    # Then, reraise so that we can handle the actual exception.
                    low_conn.close()
                    raise

        except (ProtocolError, socket.error) as err:
            raise ConnectionError(err, request=request)

        except MaxRetryError as e:
            if isinstance(e.reason, ConnectTimeoutError):
                # TODO: Remove this in 3.0.0: see #2811
                if not isinstance(e.reason, NewConnectionError):
                    raise ConnectTimeout(e, request=request)

            if isinstance(e.reason, ResponseError):
                raise RetryError(e, request=request)

            if isinstance(e.reason, _ProxyError):
                raise ProxyError(e, request=request)

            if isinstance(e.reason, _SSLError):
                # This branch is for urllib3 v1.22 and later.
                raise SSLError(e, request=request)

            raise ConnectionError(e, request=request)

        except ClosedPoolError as e:
            raise ConnectionError(e, request=request)
github Tautulli / Tautulli / lib / requests / adapters.py View on Github external
preload_content=False,
                        decode_content=False
                    )
                except:
                    # If we hit any problems here, clean up the connection.
                    # Then, reraise so that we can handle the actual exception.
                    low_conn.close()
                    raise

        except (ProtocolError, socket.error) as err:
            raise ConnectionError(err, request=request)

        except MaxRetryError as e:
            if isinstance(e.reason, ConnectTimeoutError):
                # TODO: Remove this in 3.0.0: see #2811
                if not isinstance(e.reason, NewConnectionError):
                    raise ConnectTimeout(e, request=request)

            if isinstance(e.reason, ResponseError):
                raise RetryError(e, request=request)

            if isinstance(e.reason, _ProxyError):
                raise ProxyError(e, request=request)

            if isinstance(e.reason, _SSLError):
                # This branch is for urllib3 v1.22 and later.
                raise SSLError(e, request=request)

            raise ConnectionError(e, request=request)

        except ClosedPoolError as e:
            raise ConnectionError(e, request=request)
github fga-eps-mds / 2019.1-ADA / ada / actions / report_github.py View on Github external
"📌Criada dia: {day}/{month}/{year}\n"\
                                   "📌URL: {url}".format(
                                        name=release["release"][0]["name"],
                                        body=release["release"][0]["body"],
                                        day=day, month=month, year=year,
                                        url=release["release"][0]["url"])
                    dispatcher.utter_message(release_text)
        except HTTPError:
            dispatcher.utter_message(
                "Não estou conseguindo ter acesso a seus dados, tem certeza"
                "que seus dados estão certos?")
        except ValueError:
            dispatcher.utter_message(
                "Estou com problemas para me conectar, me manda "
                "mais uma mensagem pra ver se dessa vez dá certo.")
        except NewConnectionError:
            dispatcher.utter_message(
                "Estou com problemas para me conectar, me manda "
                "mais uma mensagem pra ver se dessa vez dá certo.")
github Khan / frankenserver / python / lib / requests / requests / adapters.py View on Github external
preload_content=False,
                        decode_content=False
                    )
                except:
                    # If we hit any problems here, clean up the connection.
                    # Then, reraise so that we can handle the actual exception.
                    low_conn.close()
                    raise

        except (ProtocolError, socket.error) as err:
            raise ConnectionError(err, request=request)

        except MaxRetryError as e:
            if isinstance(e.reason, ConnectTimeoutError):
                # TODO: Remove this in 3.0.0: see #2811
                if not isinstance(e.reason, NewConnectionError):
                    raise ConnectTimeout(e, request=request)

            if isinstance(e.reason, ResponseError):
                raise RetryError(e, request=request)

            if isinstance(e.reason, _ProxyError):
                raise ProxyError(e, request=request)

            if isinstance(e.reason, _SSLError):
                # This branch is for urllib3 v1.22 and later.
                raise SSLError(e, request=request)

            raise ConnectionError(e, request=request)

        except ClosedPoolError as e:
            raise ConnectionError(e, request=request)
github fga-eps-mds / 2019.1-ADA / ada / actions / set_pipeline.py View on Github external
dispatcher.utter_message(
                "Não consegui encontrar o seu pipeline no GitLab, "
                "por favor verifique se existe um e me manda novamente.")
        except IndexError:
            dispatcher.utter_message(
                "Não consegui encontrar o seu pipeline no GitLab, "
                "por favor verifique se existe um e me manda novamente.")
        except HTTPError:
            dispatcher.utter_message(
                "Não consegui achar um pipeline no seu repositório, "
                "tenta conferir se existe um e tente novamente.")
        except ValueError:
            dispatcher.utter_message(
                "Estou com problemas para me conectar, me manda "
                "mais uma mensagem pra ver se dessa vez dá certo.")
        except NewConnectionError:
            dispatcher.utter_message(
                "Estou com problemas para me conectar, me manda "
                "mais uma mensagem pra ver se dessa vez dá certo.")