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