Revision 004042be ncclient/session/error.py
b/ncclient/session/error.py | ||
---|---|---|
17 | 17 |
class SessionError(ClientError): |
18 | 18 |
pass |
19 | 19 |
|
20 |
class RemoteClosedError(SessionError): |
|
21 |
|
|
22 |
def __init__(self, in_buf, out_buf=None): |
|
23 |
SessionError.__init__(self) |
|
24 |
self._in_buf, self._out_buf = in_buf, out_buf |
|
25 |
|
|
26 |
def __str__(self): |
|
27 |
msg = 'Session closed by remote endpoint.' |
|
28 |
if self._in_buf: |
|
29 |
msg += '\nIN_BUFFER: %s' % self._in_buf |
|
30 |
if self._out_buf: |
|
31 |
msg += '\nOUT_BUFFER: %s' % self._out_buf |
|
32 |
return msg |
|
33 |
|
|
34 |
class AuthenticationError(SessionError): |
|
35 |
pass |
|
36 |
|
|
37 | 20 |
class SSHError(SessionError): |
38 | 21 |
pass |
39 | 22 |
|
... | ... | |
48 | 31 |
return ('Unknown host key [%s] for [%s]' % |
49 | 32 |
(hexlify(self.key.get_fingerprint()), self.hostname)) |
50 | 33 |
|
51 |
class SSHAuthenticationError(AuthenticationError, SSHError): |
|
52 |
'wraps a paramiko exception that occured during auth' |
|
53 |
|
|
54 |
def __init__(self, ex): |
|
55 |
self.ex = ex |
|
34 |
class SSHAuthenticationError(SSHError): |
|
35 |
pass |
|
36 |
|
|
37 |
class SSHSessionClosedError(SSHError): |
|
56 | 38 |
|
57 |
def __repr__(self): |
|
58 |
return repr(ex) |
|
39 |
def __init__(self, in_buf, out_buf=None): |
|
40 |
SessionError.__init__(self, "Unexpected session close.") |
|
41 |
self._in_buf, self._out_buf = in_buf, out_buf |
|
42 |
|
|
43 |
def __str__(self): |
|
44 |
msg = SessionError(self).__str__() |
|
45 |
if self._in_buf: |
|
46 |
msg += '\nIN_BUFFER: %s' % self._in_buf |
|
47 |
if self._out_buf: |
|
48 |
msg += '\nOUT_BUFFER: %s' % self._out_buf |
|
49 |
return msg |
Also available in: Unified diff