Revision 7fe0bf33 ncclient/operations/listener.py
b/ncclient/operations/listener.py | ||
---|---|---|
21 | 21 |
from ncclient.content.common import unqualify as __ |
22 | 22 |
from ncclient.content.common import BASE_NS, CISCO_BS |
23 | 23 |
|
24 |
q_rpcreply = [_('rpc-reply', BASE_NS), _('rpc-reply', CISCO_BS)] |
|
25 |
|
|
24 | 26 |
class SessionListener: |
25 | 27 |
|
26 | 28 |
'''This is the glue between received data and the object it should be |
... | ... | |
56 | 58 |
|
57 | 59 |
@property |
58 | 60 |
def _recognized_elements(self): |
59 |
elems = [ 'rpc-reply' ]
|
|
61 |
elems = q_rpcreply
|
|
60 | 62 |
with self._lock: |
61 | 63 |
elems.extend(self._tag2obj.keys()) |
62 | 64 |
return elems |
... | ... | |
67 | 69 |
def received(self, raw): |
68 | 70 |
res = RootParser.parse(raw, self._recognized_elements) |
69 | 71 |
if res is not None: |
70 |
(tag, attrs) = res
|
|
72 |
tag, attrs = res # unpack
|
|
71 | 73 |
else: |
72 | 74 |
return |
73 | 75 |
logger.debug('SessionListener.reply: parsed (%r, %r)' % res) |
74 | 76 |
try: |
75 |
cb = None |
|
76 |
if tag == 'rpc-reply': |
|
77 |
id = attrs.get('message-id', None) |
|
78 |
if id is None: |
|
79 |
logger.warning('<rpc-reply> w/o message-id attr received: %s' % raw) |
|
77 |
obj = None |
|
78 |
if tag in q_rpcreply: |
|
79 |
for key in attrs: |
|
80 |
if __(key) == 'message-id': |
|
81 |
id = attrs[key] |
|
82 |
break |
|
80 | 83 |
else: |
81 |
obj = self._id2rpc.get(id, None) |
|
84 |
logger.warning('<rpc-reply> without message-id received: %s' |
|
85 |
% raw) |
|
86 |
obj = self._id2rpc.get(id, None) |
|
82 | 87 |
else: |
83 | 88 |
obj = self._tag2obj.get(tag, None) |
84 | 89 |
if obj is not None: |
Also available in: Unified diff