commit 4ba5e84354df19df6e2006e6f8a2ff8682083a43
Author: Shikhar Bhushan <shikhar@schmizz.net>
Date:   Sat Apr 25 17:39:20 2009 +0000

    debuglistener
    
    git-svn-id: http://ncclient.googlecode.com/svn/trunk@60 6dbcf712-26ac-11de-a2f3-1373824ab735

diff --git a/ncclient/__init__.py b/ncclient/__init__.py
index c1a1389..ed850f6 100644
--- a/ncclient/__init__.py
+++ b/ncclient/__init__.py
@@ -19,5 +19,14 @@ if sys.version_info < (2, 5):
 
 __version__ = "0.05"
 
-class ClientError(Exception):
+class NCClientError(Exception):
+    pass
+
+class TransportError(NCClientError):
+    pass
+
+class OperationError(NCClientError):
+    pass
+
+class ContentError(NCClientError):
     pass
diff --git a/ncclient/transport/__init__.py b/ncclient/transport/__init__.py
index e62d53e..ff53625 100644
--- a/ncclient/transport/__init__.py
+++ b/ncclient/transport/__init__.py
@@ -13,4 +13,4 @@
 # limitations under the License.
 
 import logging
-logger = logging.getLogger('ncclient.session')
\ No newline at end of file
+logger = logging.getLogger('ncclient.transport')
\ No newline at end of file
diff --git a/ncclient/transport/error.py b/ncclient/transport/error.py
index 45dc422..a472c7a 100644
--- a/ncclient/transport/error.py
+++ b/ncclient/transport/error.py
@@ -12,38 +12,29 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from ncclient import ClientError
+from ncclient import TransportError
 
-class SessionError(ClientError):
+class SSHError(TransportError):
     pass
 
-class SSHError(SessionError):
+class SSHAuthenticationError(SSHError):
     pass
 
 class SSHUnknownHostError(SSHError):
     
     def __init__(self, hostname, key):
+        from binascii import hexlify
+        SSHError(self, 'Unknown host key [%s] for [%s]'
+                 % (hexlify(key.get_fingerprint()), hostname))
         self.hostname = hostname
         self.key = key
     
-    def __str__(self):
-        from binascii import hexlify
-        return ('Unknown host key [%s] for [%s]' %
-                (hexlify(self.key.get_fingerprint()), self.hostname))
-
-class SSHAuthenticationError(SSHError):
-    pass
-
 class SSHSessionClosedError(SSHError):
     
     def __init__(self, in_buf, out_buf=None):
-        SessionError.__init__(self, "Unexpected session close.")
-        self._in_buf, self._out_buf = in_buf, out_buf
-        
-    def __str__(self):
-        msg = SessionError(self).__str__()
-        if self._in_buf:
-            msg += '\nIN_BUFFER: %s' % self._in_buf
-        if self._out_buf:
-            msg += '\nOUT_BUFFER: %s' % self._out_buf
-        return msg
\ No newline at end of file
+        msg = 'Unexpected session close.'
+        if in_buf:
+            msg += '\nIN_BUFFER: %s' % in_buf
+        if out_buf:
+            msg += '\nOUT_BUFFER: %s' % out_buf
+        SSHError.__init__(self, msg)
diff --git a/ncclient/transport/session.py b/ncclient/transport/session.py
index 2da6b3c..5a22bc4 100644
--- a/ncclient/transport/session.py
+++ b/ncclient/transport/session.py
@@ -16,7 +16,7 @@ from threading import Thread, Lock, Event
 from Queue import Queue
 
 from . import logger
-from capabilities import Capabilities, CAPABILITIES
+from ncclient.capabilities import Capabilities, CAPABILITIES
 
 
 class Subject:
@@ -149,7 +149,7 @@ class DebugListener:
         return 'DebugListener'
     
     def received(self, raw):
-        logger.debug('DebugListener:[received]:%s' % raw)
+        logger.info('DebugListener:[received]:%s' % raw)
     
     def error(self, err):
-        logger.debug('DebugListener:[error]:%s' % err)
+        logger.info('DebugListener:[error]:%s' % err)
diff --git a/ncclient/transport/ssh.py b/ncclient/transport/ssh.py
index ff0db2b..931c969 100644
--- a/ncclient/transport/ssh.py
+++ b/ncclient/transport/ssh.py
@@ -33,9 +33,8 @@ class SSHSession(Session):
 
     def __init__(self):
         Session.__init__(self)
-        self._system_host_keys = paramiko.HostKeys()
         self._host_keys = paramiko.HostKeys()
-        self._host_keys_filename = None
+        self._system_host_keys = paramiko.HostKeys()
         self._transport = None
         self._connected = False
         self._channel = None
@@ -83,24 +82,27 @@ class SSHSession(Session):
                 buf = StringIO()
                 buf.write(rest)
                 buf.seek(0)
-                state = 0
+                expect = 0
         self._buffer = buf
         self._parsing_state = expect
         self._parsing_pos = self._buffer.tell()
     
     def load_system_host_keys(self, filename=None):
         if filename is None:
-            # try the user's .ssh key file, and mask exceptions
             filename = os.path.expanduser('~/.ssh/known_hosts')
             try:
                 self._system_host_keys.load(filename)
             except IOError:
-                pass
+                # for windows
+                filename = os.path.expanduser('~/ssh/known_hosts')
+                try:
+                    self._system_host_keys.load(filename)
+                except IOError:
+                    pass
             return
         self._system_host_keys.load(filename)
     
     def load_host_keys(self, filename):
-        self._host_keys_filename = filename
         self._host_keys.load(filename)
 
     def add_host_key(self, key):
@@ -234,9 +236,9 @@ class SSHSession(Session):
                 logger.debug(e)
         
         if saved_exception is not None:
-            raise AuthenticationError(repr(saved_exception))
+            raise SSHAuthenticationError(repr(saved_exception))
         
-        raise AuthenticationError('No authentication methods available')
+        raise SSHAuthenticationError('No authentication methods available')
     
     def run(self):
         chan = self._channel
