major fix to <rpc> element namespacing - was root of most problems!
authorShikhar Bhushan <shikhar@schmizz.net>
Mon, 18 May 2009 14:01:43 +0000 (14:01 +0000)
committerShikhar Bhushan <shikhar@schmizz.net>
Mon, 18 May 2009 14:01:43 +0000 (14:01 +0000)
git-svn-id: http://ncclient.googlecode.com/svn/trunk@135 6dbcf712-26ac-11de-a2f3-1373824ab735

ncclient/operations/rpc.py
ncclient/operations/util.py
ncclient/transport/errors.py

index 9d95bf2..0832275 100644 (file)
@@ -268,8 +268,11 @@ class RPC(object):
     def _build(self, opspec):
         # internal
         spec = {
-            'tag': content.qualify('rpc'),
-            'attrib': {'message-id': self._id},
+            'tag': 'rpc',
+            'attrib': {
+                'xmlns': content.BASE_NS,
+                'message-id': self._id
+                },
             'subtree': [ opspec ]
             }
         return content.dtree2xml(spec)
index 6b2583d..21ede9f 100644 (file)
@@ -44,18 +44,16 @@ def build_filter(spec, capcheck=None):
     type = None
     if isinstance(spec, tuple):
         type, criteria = spec
-        rep = {
-            'tag': 'filter',
-            'attrib': {'type': type},
-            'subtree': criteria
-        }
+        rep = {'tag': 'filter', 'attrib': {'type': type}}
+        if type == 'xpath':
+            rep['attrib']['select'] = criteria
+        elif type == 'subtree':
+            rep['subtree'] = criteria
+        else:
+            raise OperationError("Invalid filter type")
     else:
         rep = content.validated_element(spec, ['filter', content.qualify('filter')],
                                         attrs=[('type', content.qualify('type'))])
-        try:
-            type = rep['type']
-        except KeyError:
-            type = ele[content.qualify('type')]
     if type == 'xpath' and capcheck is not None:
         capcheck(':xpath')
     return rep
index 532e452..7bee2b7 100644 (file)
@@ -23,9 +23,9 @@ class AuthenticationError(TransportError):
 class SessionCloseError(TransportError):
 
     def __init__(self, in_buf, out_buf=None):
-        msg = 'Unexpected session close.'
+        msg = 'Unexpected session close'
         if in_buf:
-            msg += ' IN_BUFFER: {%s}' % in_buf
+            msg += '\nIN_BUFFER: {%s}' % in_buf
         if out_buf:
             msg += ' OUT_BUFFER: {%s}' % out_buf
         SSHError.__init__(self, msg)