Revision d771dffc ncclient/operations/rpc.py

b/ncclient/operations/rpc.py
18 18

  
19 19
from ncclient import content
20 20

  
21
from reply import RPCReply
21
from errors import OperationError
22 22

  
23 23
import logging
24 24
logger = logging.getLogger('ncclient.rpc')
......
129 129
            return
130 130
        root = self._root = content.xml2ele(self._raw) # <rpc-reply> element
131 131
        # per rfc 4741 an <ok/> tag is sent when there are no errors or warnings
132
        ok = content.namespaced_find(root, 'ok')
132
        ok = content.find(root, 'ok')
133 133
        if ok is not None:
134 134
            logger.debug('parsed [%s]' % ok.tag)
135 135
        else: # create RPCError objects from <rpc-error> elements
136
            error = content.namespaced_find(root, 'rpc-error')
136
            error = content.find(root, 'rpc-error')
137 137
            if error is not None:
138 138
                logger.debug('parsed [%s]' % error.tag)
139 139
                for err in root.getiterator(error.tag):
......
141 141
                    d = {}
142 142
                    for err_detail in err.getchildren(): # <error-type> etc..
143 143
                        tag = content.unqualify(err_detail.tag)
144
                        d[tag] = (err_detail.text.strip() if tag != 'error-info'
145
                                  else content.ele2string(err_detail, 'utf-8'))
144
                        if tag != 'error-info':
145
                            d[tag] = err_detail.text.strip()
146
                        else:
147
                            d[tag] = content.ele2xml(err_detail)
146 148
                    self._errors.append(RPCError(d))
147 149
        self._parsing_hook(root)
148 150
        self._parsed = True
......
175 177
        return self._errors
176 178

  
177 179

  
178
class RPCError(ncclient.RPCError): # raise it if you like
180
class RPCError(OperationError): # raise it if you like
179 181
    
180 182
    def __init__(self, err_dict):
181 183
        self._dict = err_dict
182 184
        if self.message is not None:
183
            ncclient.RPCError.__init__(self, self.message)
185
            OperationError.__init__(self, self.message)
184 186
        else:
185
            ncclient.RPCError.__init__(self)
186
    
187
    @property
188
    def raw(self):
189
        return self._element.tostring()
187
            OperationError.__init__(self)
190 188
    
191 189
    @property
192 190
    def type(self):

Also available in: Unified diff