Merge
This commit is contained in:
@@ -23,6 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
import httplib
|
import httplib
|
||||||
import os.path
|
import os.path
|
||||||
@@ -220,8 +221,19 @@ class _LocalParams(_Params):
|
|||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
|
||||||
def __getattr__(self, key):
|
def __getattr__(self, key):
|
||||||
|
if key == '__setstate__': return
|
||||||
return getattr(self._delegate, key)
|
return getattr(self._delegate, key)
|
||||||
|
|
||||||
|
def __reduce__(self):
|
||||||
|
params = copy.copy(self._delegate)
|
||||||
|
kwargs = copy.copy(self.__dict__)
|
||||||
|
assert(kwargs.has_key('_delegate'))
|
||||||
|
del kwargs['_delegate']
|
||||||
|
if hasattr(params,'aux'): del params.aux
|
||||||
|
return (_LocalParams,(params,),kwargs)
|
||||||
|
|
||||||
|
def __setitem__(self, k, item):
|
||||||
|
setattr(self, k, item)
|
||||||
|
|
||||||
class ConnectionError(Exception):
|
class ConnectionError(Exception):
|
||||||
"""Detailed exception class for reporting on http connection problems.
|
"""Detailed exception class for reporting on http connection problems.
|
||||||
@@ -324,6 +336,14 @@ class BadRequest(ConnectionError):
|
|||||||
""" 400 Bad Request """
|
""" 400 Bad Request """
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class Unauthorized(ConnectionError):
|
||||||
|
""" 401 Unauthorized """
|
||||||
|
pass
|
||||||
|
|
||||||
|
class PaymentRequired(ConnectionError):
|
||||||
|
""" 402 Payment Required """
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Forbidden(ConnectionError):
|
class Forbidden(ConnectionError):
|
||||||
""" 403 Forbidden """
|
""" 403 Forbidden """
|
||||||
@@ -339,18 +359,43 @@ class Gone(ConnectionError):
|
|||||||
""" 410 Gone """
|
""" 410 Gone """
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class LengthRequired(ConnectionError):
|
||||||
|
""" 411 Length Required """
|
||||||
|
pass
|
||||||
|
|
||||||
|
class RequestURITooLong(ConnectionError):
|
||||||
|
""" 414 Request-URI Too Long """
|
||||||
|
pass
|
||||||
|
|
||||||
|
class UnsupportedMediaType(ConnectionError):
|
||||||
|
""" 415 Unsupported Media Type """
|
||||||
|
pass
|
||||||
|
|
||||||
|
class RequestedRangeNotSatisfiable(ConnectionError):
|
||||||
|
""" 416 Requested Range Not Satisfiable """
|
||||||
|
pass
|
||||||
|
|
||||||
|
class ExpectationFailed(ConnectionError):
|
||||||
|
""" 417 Expectation Failed """
|
||||||
|
pass
|
||||||
|
|
||||||
|
class NotImplemented(ConnectionError):
|
||||||
|
""" 501 Not Implemented """
|
||||||
|
pass
|
||||||
|
|
||||||
class ServiceUnavailable(Retriable):
|
class ServiceUnavailable(Retriable):
|
||||||
""" 503 Service Unavailable """
|
""" 503 Service Unavailable """
|
||||||
def url(self):
|
def url(self):
|
||||||
return self.params._delegate.url
|
return self.params._delegate.url
|
||||||
|
|
||||||
|
|
||||||
class GatewayTimeout(Retriable):
|
class GatewayTimeout(Retriable):
|
||||||
""" 504 Gateway Timeout """
|
""" 504 Gateway Timeout """
|
||||||
def url(self):
|
def url(self):
|
||||||
return self.params._delegate.url
|
return self.params._delegate.url
|
||||||
|
|
||||||
|
class HTTPVersionNotSupported(ConnectionError):
|
||||||
|
""" 505 HTTP Version Not Supported """
|
||||||
|
pass
|
||||||
|
|
||||||
class InternalServerError(ConnectionError):
|
class InternalServerError(ConnectionError):
|
||||||
""" 500 Internal Server Error """
|
""" 500 Internal Server Error """
|
||||||
@@ -389,12 +434,21 @@ status_to_error_map = {
|
|||||||
304: NotModified,
|
304: NotModified,
|
||||||
307: TemporaryRedirect,
|
307: TemporaryRedirect,
|
||||||
400: BadRequest,
|
400: BadRequest,
|
||||||
|
401: Unauthorized,
|
||||||
|
402: PaymentRequired,
|
||||||
403: Forbidden,
|
403: Forbidden,
|
||||||
404: NotFound,
|
404: NotFound,
|
||||||
410: Gone,
|
410: Gone,
|
||||||
|
411: LengthRequired,
|
||||||
|
414: RequestURITooLong,
|
||||||
|
415: UnsupportedMediaType,
|
||||||
|
416: RequestedRangeNotSatisfiable,
|
||||||
|
417: ExpectationFailed,
|
||||||
500: InternalServerError,
|
500: InternalServerError,
|
||||||
|
501: NotImplemented,
|
||||||
503: ServiceUnavailable,
|
503: ServiceUnavailable,
|
||||||
504: GatewayTimeout,
|
504: GatewayTimeout,
|
||||||
|
505: HTTPVersionNotSupported,
|
||||||
}
|
}
|
||||||
|
|
||||||
scheme_to_factory_map = {
|
scheme_to_factory_map = {
|
||||||
|
Reference in New Issue
Block a user