Revision d6688264 ncclient/rpc/reply.py
b/ncclient/rpc/reply.py | ||
---|---|---|
38 | 38 |
if __(root.tag) != 'rpc-reply': |
39 | 39 |
raise ValueError('Root element is not RPC reply') |
40 | 40 |
|
41 |
ok = False |
|
41 | 42 |
# per rfc 4741 an <ok/> tag is sent when there are no errors or warnings |
42 | 43 |
oktags = _('ok') |
43 | 44 |
for oktag in oktags: |
44 | 45 |
if root.find(oktag) is not None: |
45 | 46 |
logger.debug('parsed [%s]' % oktag) |
46 |
self._parsed = True |
|
47 |
return |
|
48 |
|
|
49 |
# create RPCError objects from <rpc-error> elements |
|
50 |
errtags = _('rpc-error') |
|
51 |
for errtag in errtags: |
|
52 |
for err in root.getiterator(errtag): # a particular <rpc-error> |
|
53 |
logger.debug('parsed [%s]' % errtag) |
|
54 |
d = {} |
|
55 |
for err_detail in err.getchildren(): # <error-type> etc.. |
|
56 |
tag = __(err_detail.tag) |
|
57 |
d[tag] = (err_detail.text.strip() if tag != 'error-info' |
|
58 |
else ET.tostring(err_detail, 'utf-8')) |
|
59 |
self._errors.append(RPCError(d)) |
|
60 |
if self._errors: |
|
61 | 47 |
break |
48 |
else: |
|
49 |
# create RPCError objects from <rpc-error> elements |
|
50 |
errtags = _('rpc-error') |
|
51 |
for errtag in errtags: |
|
52 |
for err in root.getiterator(errtag): # a particular <rpc-error> |
|
53 |
logger.debug('parsed [%s]' % errtag) |
|
54 |
d = {} |
|
55 |
for err_detail in err.getchildren(): # <error-type> etc.. |
|
56 |
tag = __(err_detail.tag) |
|
57 |
d[tag] = (err_detail.text.strip() if tag != 'error-info' |
|
58 |
else ET.tostring(err_detail, 'utf-8')) |
|
59 |
self._errors.append(RPCError(d)) |
|
60 |
if self._errors: |
|
61 |
break |
|
62 |
|
|
63 |
if self.ok: |
|
64 |
# TODO: store children in some way... |
|
65 |
pass |
|
62 | 66 |
|
63 | 67 |
self._parsed = True |
64 | 68 |
|
Also available in: Unified diff