|
|
|
@ -24,6 +24,7 @@ The :mod:`networkbase` module defines the base classes for all networks.
|
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
import logging |
|
|
|
|
import gettext |
|
|
|
|
|
|
|
|
|
from mitterlib.constants import version |
|
|
|
|
|
|
|
|
@ -39,6 +40,12 @@ def auth_options(namespace, options, auths):
|
|
|
|
|
default=None, |
|
|
|
|
help=option['help'], |
|
|
|
|
*(option['flags'])) |
|
|
|
|
#-------------------------------------------------------------------- |
|
|
|
|
# i18n |
|
|
|
|
#-------------------------------------------------------------------- |
|
|
|
|
t = gettext.translation('networks', fallback=True) |
|
|
|
|
_ = t.gettext |
|
|
|
|
N_ = t.ngettext |
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
|
|
|
# Exceptions |
|
|
|
@ -56,36 +63,77 @@ class NetworkUnknownError(NetworkError):
|
|
|
|
|
|
|
|
|
|
class NetworkLimitExceededError(NetworkError): |
|
|
|
|
"""The number of requests available was exceeded.""" |
|
|
|
|
|
|
|
|
|
def __init__(self, network_name): |
|
|
|
|
self.name = network_name |
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
|
return _('No more available requests on %s') % (self.name) |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NetworkDNSError(NetworkError): |
|
|
|
|
"""A DNS failure prevented the request to continue.""" |
|
|
|
|
|
|
|
|
|
def __init__(self, network_name): |
|
|
|
|
self.name = network_name |
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
|
return _('DNS failure on a request to %s') % (self.name) |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NetworkInvalidResponseError(NetworkError): |
|
|
|
|
"""The server returned the information in an unexpected way.""" |
|
|
|
|
|
|
|
|
|
def __init__(self, network_name): |
|
|
|
|
self.name = network_name |
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
|
return _('The server on %s return the information in an ' \ |
|
|
|
|
'unexpected way.') % (self.name) |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NetworkLowLevelError(NetworkError): |
|
|
|
|
"""A low level error occurred in the network layer.""" |
|
|
|
|
|
|
|
|
|
def __init__(self, network_name): |
|
|
|
|
self.name = network_name |
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
|
return _('Low level error in the network layer when talking ' \ |
|
|
|
|
'to %s') % (self.name) |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NetworkBadStatusLineError(NetworkError): |
|
|
|
|
"""Bad status line exception.""" |
|
|
|
|
def __init__(self, network_name): |
|
|
|
|
self.name = network_name |
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
|
return _('Bad status line in network %s') % (self.name) |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NetworkAuthorizationFailError(NetworkError): |
|
|
|
|
"""Authorization failure.""" |
|
|
|
|
def __init__(self, network_name): |
|
|
|
|
self.name = network_name |
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
|
return _('Autorization failed for %s') % (self.name) |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NetworkPermissionDeniedError(NetworkError): |
|
|
|
|
"""Permission denied when accessing the message/list.""" |
|
|
|
|
def __init__(self, network_name): |
|
|
|
|
self.name = network_name |
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
|
return _('Permission denied received on %s') % (self.name) |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
|
|
@ -99,6 +147,11 @@ class NetworkWarning(Warning):
|
|
|
|
|
|
|
|
|
|
class MessageTooLongWarning(NetworkWarning): |
|
|
|
|
"""The message is too long for the network.""" |
|
|
|
|
def __init__(self, network_name): |
|
|
|
|
self.name = network_name |
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
|
return _('Message too long for %s') % (self.name) |
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------- |
|
|
|
|