Revision 6c70b245

b/ncclient/manager.py
35 35
#: Same as :meth:`connect_ssh`
36 36
connect = connect_ssh
37 37

  
38
class RAISE:
39
    ALL = 0
40
    ERRORS = 1
41
    NONE = 2
42

  
43 38
class Manager(object):
44 39

  
45 40
    """API for NETCONF operations.
......
51 46
        self._session = session
52 47
        self._async_mode = False
53 48
        self._timeout = None
49
        self._raise_mode = 'all'
54 50

  
55 51
    def __enter__(self):
56 52
        return self
......
67 63
        else:
68 64
            return op(self.session,
69 65
                      async=self._async_mode,
70
                      raising=self._raise_mode,
71
                      timeout=self.timeout).request
66
                      timeout=self.timeout,
67
                      raise_mode=self._raise_mode).request
72 68

  
73 69
    def locked(self, target):
74 70
        """Returns a context manager for the *with* statement.
......
116 112
    def set_async_mode(self, bool=True):
117 113
        self._async_mode = bool
118 114

  
119
    def set_raise_mode(self, choice='all'):
120
        self._raise_mode = choice
115
    def set_raise_mode(self, mode):
116
        assert(choice in ('all', 'errors', 'none'))
117
        self._raise_mode = mode
121 118

  
122 119
    async_mode = property(fget=lambda self: self._async_mode, fset=set_async_mode)
123 120

  
b/ncclient/operations/rpc.py
249 249
    # subclass of :class:`RPCReply`.
250 250
    REPLY_CLS = RPCReply
251 251

  
252
    def __init__(self, session, async=False, timeout=None):
252
    def __init__(self, session, async=False, timeout=None, raise_mode='none'):
253 253
        self._session = session
254 254
        try:
255 255
            for cap in self.DEPENDS:
......
258 258
            pass
259 259
        self._async = async
260 260
        self._timeout = timeout
261
        self._raise_mode = raise_mode
261 262
        # keeps things simple instead of having a class attr that has to be locked
262 263
        self._id = uuid1().urn
263
        # RPCReplyListener itself makes sure there isn't more than one instance -- i.e. multiton
264 264
        self._listener = RPCReplyListener(session)
265 265
        self._listener.register(self._id, self)
266 266
        self._reply = None
......
305 305
            self._event.wait(self._timeout)
306 306
            if self._event.isSet():
307 307
                if self._error:
308
                    # Error that prevented reply delivery
308 309
                    raise self._error
309 310
                self._reply.parse()
311
                if self._reply.error is not None:
312
                    # <rpc-error>'s [ RPCError ]
313
                    if self._raise_mode == "all":
314
                        raise self._reply._error
315
                    elif (self._raise_mode == "errors" and
316
                          self._reply.error.type == "error"):
317
                        raise self._reply.error
310 318
                return self._reply
311 319
            else:
312 320
                raise TimeoutExpiredError
......
315 323
        """Subclasses implement this method. Here, the operation is constructed
316 324
        in :ref:`dtree`, and the result of :meth:`_request` returned."""
317 325
        return self._request(self.SPEC)
318

  
319
    #def _delivery_hook(self):
320
    #    """Subclasses can implement this method. Will be called after
321
    #    initialising the :attr:`reply` or :attr:`error` attribute and before
322
    #    setting the :attr:`event`"""
323
    #    pass
324

  
326
    
325 327
    def _assert(self, capability):
326 328
        """Subclasses can use this method to verify that a capability is available
327 329
        with the NETCONF server, before making a request that requires it. A
......
386 388
        if async and not session.can_pipeline:
387 389
            raise UserWarning('Asynchronous mode not supported for this device/session')
388 390

  
389
    def set_raise_mode(self, choice):
391
    def set_raise_mode(self, mode):
390 392
        assert(choice in ('all', 'errors', 'none'))
391
        self._raise = choice
393
        self._raise_mode = mode
392 394

  
393 395
    def set_timeout(self, timeout):
394 396
        """Set the timeout for synchronous waiting defining how long the RPC

Also available in: Unified diff