Revision 4ba5e843

b/ncclient/__init__.py
19 19

  
20 20
__version__ = "0.05"
21 21

  
22
class ClientError(Exception):
22
class NCClientError(Exception):
23
    pass
24

  
25
class TransportError(NCClientError):
26
    pass
27

  
28
class OperationError(NCClientError):
29
    pass
30

  
31
class ContentError(NCClientError):
23 32
    pass
b/ncclient/transport/__init__.py
13 13
# limitations under the License.
14 14

  
15 15
import logging
16
logger = logging.getLogger('ncclient.session')
16
logger = logging.getLogger('ncclient.transport')
b/ncclient/transport/error.py
12 12
# See the License for the specific language governing permissions and
13 13
# limitations under the License.
14 14

  
15
from ncclient import ClientError
15
from ncclient import TransportError
16 16

  
17
class SessionError(ClientError):
17
class SSHError(TransportError):
18 18
    pass
19 19

  
20
class SSHError(SessionError):
20
class SSHAuthenticationError(SSHError):
21 21
    pass
22 22

  
23 23
class SSHUnknownHostError(SSHError):
24 24
    
25 25
    def __init__(self, hostname, key):
26
        from binascii import hexlify
27
        SSHError(self, 'Unknown host key [%s] for [%s]'
28
                 % (hexlify(key.get_fingerprint()), hostname))
26 29
        self.hostname = hostname
27 30
        self.key = key
28 31
    
29
    def __str__(self):
30
        from binascii import hexlify
31
        return ('Unknown host key [%s] for [%s]' %
32
                (hexlify(self.key.get_fingerprint()), self.hostname))
33

  
34
class SSHAuthenticationError(SSHError):
35
    pass
36

  
37 32
class SSHSessionClosedError(SSHError):
38 33
    
39 34
    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
35
        msg = 'Unexpected session close.'
36
        if in_buf:
37
            msg += '\nIN_BUFFER: %s' % in_buf
38
        if out_buf:
39
            msg += '\nOUT_BUFFER: %s' % out_buf
40
        SSHError.__init__(self, msg)
b/ncclient/transport/session.py
16 16
from Queue import Queue
17 17

  
18 18
from . import logger
19
from capabilities import Capabilities, CAPABILITIES
19
from ncclient.capabilities import Capabilities, CAPABILITIES
20 20

  
21 21

  
22 22
class Subject:
......
149 149
        return 'DebugListener'
150 150
    
151 151
    def received(self, raw):
152
        logger.debug('DebugListener:[received]:%s' % raw)
152
        logger.info('DebugListener:[received]:%s' % raw)
153 153
    
154 154
    def error(self, err):
155
        logger.debug('DebugListener:[error]:%s' % err)
155
        logger.info('DebugListener:[error]:%s' % err)
b/ncclient/transport/ssh.py
33 33

  
34 34
    def __init__(self):
35 35
        Session.__init__(self)
36
        self._system_host_keys = paramiko.HostKeys()
37 36
        self._host_keys = paramiko.HostKeys()
38
        self._host_keys_filename = None
37
        self._system_host_keys = paramiko.HostKeys()
39 38
        self._transport = None
40 39
        self._connected = False
41 40
        self._channel = None
......
83 82
                buf = StringIO()
84 83
                buf.write(rest)
85 84
                buf.seek(0)
86
                state = 0
85
                expect = 0
87 86
        self._buffer = buf
88 87
        self._parsing_state = expect
89 88
        self._parsing_pos = self._buffer.tell()
90 89
    
91 90
    def load_system_host_keys(self, filename=None):
92 91
        if filename is None:
93
            # try the user's .ssh key file, and mask exceptions
94 92
            filename = os.path.expanduser('~/.ssh/known_hosts')
95 93
            try:
96 94
                self._system_host_keys.load(filename)
97 95
            except IOError:
98
                pass
96
                # for windows
97
                filename = os.path.expanduser('~/ssh/known_hosts')
98
                try:
99
                    self._system_host_keys.load(filename)
100
                except IOError:
101
                    pass
99 102
            return
100 103
        self._system_host_keys.load(filename)
101 104
    
102 105
    def load_host_keys(self, filename):
103
        self._host_keys_filename = filename
104 106
        self._host_keys.load(filename)
105 107

  
106 108
    def add_host_key(self, key):
......
234 236
                logger.debug(e)
235 237
        
236 238
        if saved_exception is not None:
237
            raise AuthenticationError(repr(saved_exception))
239
            raise SSHAuthenticationError(repr(saved_exception))
238 240
        
239
        raise AuthenticationError('No authentication methods available')
241
        raise SSHAuthenticationError('No authentication methods available')
240 242
    
241 243
    def run(self):
242 244
        chan = self._channel

Also available in: Unified diff