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)
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
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)