Revision c8381a66 ncclient/manager.py

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

  
38 43
class Manager(object):
39 44

  
40 45
    """API for NETCONF operations.
......
44 49

  
45 50
    def __init__(self, session):
46 51
        self._session = session
52
        self._async_mode = False
53
        self._timeout = None
47 54

  
48 55
    def __enter__(self):
49 56
        return self
50 57

  
51
    def __exit__(self, *args):
58
    def __exit__(self, *argss):
52 59
        self.close()
53 60
        return False
54 61

  
55 62
    def __getattr__(self, name):
56 63
        try:
57
            return operations.INDEX[name](self.session).request
64
            op = operations.INDEX[name]
58 65
        except KeyError:
59 66
            raise AttributeError
67
        else:
68
            return op(self.session,
69
                      async=self._async_mode,
70
                      raising=self._raise_mode,
71
                      timeout=self.timeout).request
60 72

  
61 73
    def locked(self, target):
62 74
        """Returns a context manager for the *with* statement.
......
100 112
    def connected(self):
101 113
        "Whether currently connected to NETCONF server"
102 114
        return self._session.connected
115

  
116
    def set_async_mode(self, bool=True):
117
        self._async_mode = bool
118

  
119
    def set_raise_mode(self, choice='all'):
120
        self._raise_mode = choice
121

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

  
124
    raise_mode = property(fget=set_raise_mode, fset=set_raise_mode)

Also available in: Unified diff