Python google.appengine.api.urlfetch.InvalidURLError() Examples
The following are 3
code examples of google.appengine.api.urlfetch.InvalidURLError().
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
google.appengine.api.urlfetch
, or try the search function
.
Example #1
Source File: http_client.py From pledgeservice with Apache License 2.0 | 6 votes |
def _handle_request_error(self, e, url): if isinstance(e, urlfetch.InvalidURLError): msg = ("The Stripe library attempted to fetch an " "invalid URL (%r). This is likely due to a bug " "in the Stripe Python bindings. Please let us know " "at support@stripe.com." % (url,)) elif isinstance(e, urlfetch.DownloadError): msg = "There was a problem retrieving data from Stripe." elif isinstance(e, urlfetch.ResponseTooLargeError): msg = ("There was a problem receiving all of your data from " "Stripe. This is likely due to a bug in Stripe. " "Please let us know at support@stripe.com.") else: msg = ("Unexpected error communicating with Stripe. If this " "problem persists, let us know at support@stripe.com.") msg = textwrap.fill(msg) + "\n\n(Network error: " + str(e) + ")" raise error.APIConnectionError(msg)
Example #2
Source File: http_client.py From shippo-python-client with MIT License | 6 votes |
def _handle_request_error(self, e, url): if isinstance(e, urlfetch.InvalidURLError): msg = ("The Shippo library attempted to fetch an " "invalid URL (%r). This is likely due to a bug " "in the Shippo Python bindings. Please let us know " "at support@goshippo.com." % (url,)) elif isinstance(e, urlfetch.DownloadError): msg = "There was a problem retrieving data from Shippo." elif isinstance(e, urlfetch.ResponseTooLargeError): msg = ("There was a problem receiving all of your data from " "Shippo. This is likely due to a bug in Shippo. " "Please let us know at support@goshippo.com.") else: msg = ("Unexpected error communicating with Shippo. If this " "problem persists, let us know at support@goshippo.com.") msg = textwrap.fill(msg) + "\n\n(Network error: " + str(e) + ")" raise error.APIConnectionError(msg)
Example #3
Source File: httplib.py From python-compat-runtime with Apache License 2.0 | 4 votes |
def getresponse(self, buffering=False): """Get the response from the server. App Engine Note: buffering is ignored. """ # net.proto.ProcotolBuffer relies on httplib so importing urlfetch at the # module level causes a failure on prod. That means the import needs to be # lazy. from google.appengine.api import urlfetch import socket # Cannot be done at global scope due to circular import. if self.port and self.port != self.default_port: host = '%s:%s' % (self.host, self.port) else: host = self.host if not self._url.startswith(self._protocol): url = '%s://%s%s' % (self._protocol, host, self._url) else: url = self._url headers = dict(self.headers) if self.timeout in [_GLOBAL_DEFAULT_TIMEOUT, socket._GLOBAL_DEFAULT_TIMEOUT]: deadline = socket.getdefaulttimeout() else: deadline = self.timeout try: method = self._method_map[self._method.upper()] except KeyError: raise ValueError('%r is an unrecognized HTTP method' % self._method) try: # The Python Standard Library doesn't validate certificates so don't # validate them here either. But some libraries (httplib2, possibly # others) use an alternate technique where the fetch function does not # have a validate_certificate argument so only provide it when supported. argspec = self._getargspec(self._fetch) extra_kwargs = ( {'validate_certificate': False} if argspec.keywords or 'validate_certificate' in argspec.args else {}) fetch_response = self._fetch(url, self._body, method, headers, self._allow_truncated, self._follow_redirects, deadline, **extra_kwargs) except urlfetch.InvalidURLError, e: raise InvalidURL(str(e))