| 1 |
|
| 2 |
""" |
| 3 |
pyxs |
| 4 |
~~~~ |
| 5 |
|
| 6 |
Pure Python bindings for communicating with XenStore. |
| 7 |
|
| 8 |
:copyright: (c) 2011 by Selectel, see AUTHORS for more details. |
| 9 |
:license: LGPL, see LICENSE for more details. |
| 10 |
""" |
| 11 |
|
| 12 |
__all__ = ["Router", "Client", "Monitor", |
| 13 |
"PyXSError", "ConnectionError", "UnexpectedPacket", |
| 14 |
"InvalidOperation", "InvalidPath", "InvalidPayload", |
| 15 |
"xs", "Error"] |
| 16 |
|
| 17 |
from contextlib import contextmanager |
| 18 |
|
| 19 |
from .client import Router, Client, Monitor |
| 20 |
from .exceptions import PyXSError, ConnectionError, UnexpectedPacket, \ |
| 21 |
InvalidOperation, InvalidPath, InvalidPayload |
| 22 |
from ._compat import xs, Error |
| 23 |
|
| 24 |
|
| 25 |
@contextmanager |
| 26 |
def monitor(*args, **kwargs): |
| 27 |
"""A simple shortcut for creating :class:`~pyxs.client.Monitor` |
| 28 |
instances. All arguments are forwared to :class:`~pyxs.client.Client` |
| 29 |
constructor. |
| 30 |
""" |
| 31 |
with Client(*args, **kwargs) as c: |
| 32 |
with c.monitor() as m: |
| 33 |
yield m |