How to use the sparkmagic.livyclientlib.exceptions.HttpClientException function in sparkmagic

To help you get started, we’ve selected a few sparkmagic 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 jupyter-incubator / sparkmagic / sparkmagic / sparkmagic / livyclientlib / reliablehttpclient.py View on Github external
text = None

                self.logger.error(u"Request to '{}' failed with '{}'".format(url, e))
            else:
                error = False
                status = r.status_code
                text = r.text

            if error or status not in accepted_status_codes:
                if self._retry_policy.should_retry(status, error, retry_count):
                    sleep(self._retry_policy.seconds_to_sleep(retry_count))
                    retry_count += 1
                    continue

                if error:
                    raise HttpClientException(u"Error sending http request and maximum retry encountered.")
                else:
                    raise HttpClientException(u"Invalid status code '{}' from {} with error payload: {}"
                                              .format(status, url, text))
            return r
github jupyter-incubator / sparkmagic / sparkmagic / sparkmagic / livyclientlib / reliablehttpclient.py View on Github external
self.logger.error(u"Request to '{}' failed with '{}'".format(url, e))
            else:
                error = False
                status = r.status_code
                text = r.text

            if error or status not in accepted_status_codes:
                if self._retry_policy.should_retry(status, error, retry_count):
                    sleep(self._retry_policy.seconds_to_sleep(retry_count))
                    retry_count += 1
                    continue

                if error:
                    raise HttpClientException(u"Error sending http request and maximum retry encountered.")
                else:
                    raise HttpClientException(u"Invalid status code '{}' from {} with error payload: {}"
                                              .format(status, url, text))
            return r
github jupyter-incubator / sparkmagic / sparkmagic / sparkmagic / controllerwidget / manageendpointwidget.py View on Github external
def get_existing_endpoint_widgets(self):
        endpoint_widgets = []
        endpoint_widgets.append(self.ipywidget_factory.get_html(value="<br>", width="600px"))

        if len(self.endpoints) &gt; 0:
            # Header
            header = self.ipywidget_factory.get_html(value="Endpoint")
            endpoint_widgets.append(header)

            # Endpoints
            for url, endpoint in self.endpoints.items():
                try:
                    endpoint_widgets.append(self.get_endpoint_widget(url, endpoint))
                except HttpClientException:
                    # If we can't reach one of the default endpoints, just skip over it
                    if not endpoint.implicitly_added:
                        raise
                    else:
                        self.logger.info("Failed to connect to implicitly-defined endpoint at: %s" % url)

            endpoint_widgets.append(self.ipywidget_factory.get_html(value="<br>", width="600px"))
        else:
            endpoint_widgets.append(self.ipywidget_factory.get_html(value="No endpoints yet.", width="600px"))

        return endpoint_widgets