File: __init__.py

package info (click to toggle)
python-pyxs 0.4.2~git20190115.97f14313-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 332 kB
  • sloc: python: 1,196; makefile: 93
file content (33 lines) | stat: -rw-r--r-- 966 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8 -*-
"""
    pyxs
    ~~~~

    Pure Python bindings for communicating with XenStore.

    :copyright: (c) 2011 by Selectel, see AUTHORS for more details.
    :license: LGPL, see LICENSE for more details.
"""

__all__ = ["Router", "Client", "Monitor",
           "PyXSError", "ConnectionError", "UnexpectedPacket",
           "InvalidOperation", "InvalidPath", "InvalidPayload",
           "xs", "Error"]

from contextlib import contextmanager

from .client import Router, Client, Monitor
from .exceptions import PyXSError, ConnectionError, UnexpectedPacket, \
    InvalidOperation, InvalidPath, InvalidPayload
from ._compat import xs, Error


@contextmanager
def monitor(*args, **kwargs):
    """A simple shortcut for creating :class:`~pyxs.client.Monitor`
    instances. All arguments are forwared to :class:`~pyxs.client.Client`
    constructor.
    """
    with Client(*args, **kwargs) as c:
        with c.monitor() as m:
            yield m