Statistics
| Branch: | Tag: | Revision:

root / ncclient / transport / error.py @ 4ba5e843

History | View | Annotate | Download (1.3 kB)

1 d095a59e Shikhar Bhushan
# Copyright 2009 Shikhar Bhushan
2 d095a59e Shikhar Bhushan
#
3 d095a59e Shikhar Bhushan
# Licensed under the Apache License, Version 2.0 (the "License");
4 d095a59e Shikhar Bhushan
# you may not use this file except in compliance with the License.
5 d095a59e Shikhar Bhushan
# You may obtain a copy of the License at
6 d095a59e Shikhar Bhushan
#
7 d095a59e Shikhar Bhushan
#    http://www.apache.org/licenses/LICENSE-2.0
8 d095a59e Shikhar Bhushan
#
9 d095a59e Shikhar Bhushan
# Unless required by applicable law or agreed to in writing, software
10 d095a59e Shikhar Bhushan
# distributed under the License is distributed on an "AS IS" BASIS,
11 d095a59e Shikhar Bhushan
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 d095a59e Shikhar Bhushan
# See the License for the specific language governing permissions and
13 d095a59e Shikhar Bhushan
# limitations under the License.
14 d095a59e Shikhar Bhushan
15 4ba5e843 Shikhar Bhushan
from ncclient import TransportError
16 d095a59e Shikhar Bhushan
17 4ba5e843 Shikhar Bhushan
class SSHError(TransportError):
18 d095a59e Shikhar Bhushan
    pass
19 d095a59e Shikhar Bhushan
20 4ba5e843 Shikhar Bhushan
class SSHAuthenticationError(SSHError):
21 d095a59e Shikhar Bhushan
    pass
22 d095a59e Shikhar Bhushan
23 d095a59e Shikhar Bhushan
class SSHUnknownHostError(SSHError):
24 d095a59e Shikhar Bhushan
    
25 d095a59e Shikhar Bhushan
    def __init__(self, hostname, key):
26 4ba5e843 Shikhar Bhushan
        from binascii import hexlify
27 4ba5e843 Shikhar Bhushan
        SSHError(self, 'Unknown host key [%s] for [%s]'
28 4ba5e843 Shikhar Bhushan
                 % (hexlify(key.get_fingerprint()), hostname))
29 d095a59e Shikhar Bhushan
        self.hostname = hostname
30 d095a59e Shikhar Bhushan
        self.key = key
31 d095a59e Shikhar Bhushan
    
32 d095a59e Shikhar Bhushan
class SSHSessionClosedError(SSHError):
33 d095a59e Shikhar Bhushan
    
34 d095a59e Shikhar Bhushan
    def __init__(self, in_buf, out_buf=None):
35 4ba5e843 Shikhar Bhushan
        msg = 'Unexpected session close.'
36 4ba5e843 Shikhar Bhushan
        if in_buf:
37 4ba5e843 Shikhar Bhushan
            msg += '\nIN_BUFFER: %s' % in_buf
38 4ba5e843 Shikhar Bhushan
        if out_buf:
39 4ba5e843 Shikhar Bhushan
            msg += '\nOUT_BUFFER: %s' % out_buf
40 4ba5e843 Shikhar Bhushan
        SSHError.__init__(self, msg)