- TransactionalHandler, DictSubHandler, call
-
-__all__ = ('PppHandler')
-
-
-class ConnectionError(HandlerError, KeyError):
- r"""
- ConnectionError(hostname) -> ConnectionError instance
-
- This is the base exception for all connection related errors.
- """
-
- def __init__(self, connection):
- r"Initialize the object. See class documentation for more info."
- self.message = u'Connection error: "%s"' % connection
-
-class ConnectionNotFoundError(ConnectionError):
- def __init__(self, connection):
- r"Initialize the object. See class documentation for more info."
- self.message = u'Connection not found error: "%s"' % connection
-
-class Connection(Sequence):
-
- def __init__(self, name, username, password, type, **kw):
- self.name = name
- self.username = username
- self.password = password
- self.type = type
- self._running = False
- if type == 'OE':
- if not 'device' in kw:
- raise ConnectionError('Bad arguments for type=OE')
- self.device = kw['device']
- elif type == 'TUNNEL':
- if not 'server' in kw:
- raise ConnectionError('Bad arguments for type=TUNNEL')
- self.server = kw['server']
- self.username = self.username.replace('\\','\\\\')
- elif type == 'PPP':
- if not 'device' in kw:
- raise ConnectionError('Bad arguments for type=PPP')
- self.device = kw['device']
- else:
- raise ConnectionError('Bad arguments, unknown or unspecified type')
-
- def as_tuple(self):
- if self.type == 'TUNNEL':
- return (self.name, self.username, self.password, self.type, self.server)
- elif self.type == 'PPP' or self.type == 'OE':
- return (self.name, self.username, self.password, self.type, self.device)
-
- def update(self, device=None, username=None, password=None):
- if device is not None:
- self.device = device
- if username is not None:
- self.username = username
- if password is not None:
- self.password = password
-