Revision 0304f041 ncclient/operations/lock.py
b/ncclient/operations/lock.py | ||
---|---|---|
75 | 75 |
|
76 | 76 |
""" |
77 | 77 |
A context manager for the :class:`Lock` / :class:`Unlock` pair of RPC's. |
78 |
|
|
78 |
|
|
79 |
RPC errors are always raised as exceptions. |
|
80 |
|
|
79 | 81 |
Initialise with session instance (:class:`Session |
80 | 82 |
<ncclient.transport.Session>`) and lock target (:ref:`source_target`) |
81 | 83 |
""" |
... | ... | |
86 | 88 |
|
87 | 89 |
def __enter__(self): |
88 | 90 |
reply = Lock(self.session).request(self.target) |
89 |
if not reply.ok: |
|
91 |
if not reply.ok: # an error locking should definitely always be raised
|
|
90 | 92 |
raise reply.error |
91 | 93 |
else: |
92 | 94 |
return self |
Also available in: Unified diff