| 1 |
"""An implementation of the varlink protocol |
| 2 |
|
| 3 |
See https://www.varlink.org for more information about the varlink protocol and interface definition |
| 4 |
files. |
| 5 |
|
| 6 |
For server implementations use the :class:`varlink.Server` class. |
| 7 |
|
| 8 |
For client implementations use the :class:`varlink.Client` class. |
| 9 |
|
| 10 |
For installation and examples, see the GIT repository https://github.com/varlink/python. |
| 11 |
or the `source code <_modules/varlink/tests/test_orgexamplemore.html>`_ of |
| 12 |
:mod:`varlink.tests.test_orgexamplemore` |
| 13 |
|
| 14 |
""" |
| 15 |
|
| 16 |
import os |
| 17 |
|
| 18 |
if hasattr(os, "fork"): |
| 19 |
__all__ = [ |
| 20 |
"Client", |
| 21 |
"ClientInterfaceHandler", |
| 22 |
"SimpleClientInterfaceHandler", |
| 23 |
"Service", |
| 24 |
"RequestHandler", |
| 25 |
"Server", |
| 26 |
"ThreadingServer", |
| 27 |
"ForkingServer", |
| 28 |
"InterfaceNotFound", |
| 29 |
"MethodNotFound", |
| 30 |
"MethodNotImplemented", |
| 31 |
"InvalidParameter", |
| 32 |
"VarlinkEncoder", |
| 33 |
"VarlinkError", |
| 34 |
"Interface", |
| 35 |
"Scanner", |
| 36 |
"get_listen_fd", |
| 37 |
] |
| 38 |
from .server import ForkingServer |
| 39 |
else: |
| 40 |
__all__ = [ |
| 41 |
"Client", |
| 42 |
"ClientInterfaceHandler", |
| 43 |
"SimpleClientInterfaceHandler", |
| 44 |
"Service", |
| 45 |
"RequestHandler", |
| 46 |
"Server", |
| 47 |
"ThreadingServer", |
| 48 |
"InterfaceNotFound", |
| 49 |
"MethodNotFound", |
| 50 |
"MethodNotImplemented", |
| 51 |
"InvalidParameter", |
| 52 |
"VarlinkEncoder", |
| 53 |
"VarlinkError", |
| 54 |
"Interface", |
| 55 |
"Scanner", |
| 56 |
"get_listen_fd", |
| 57 |
] |
| 58 |
|
| 59 |
from .client import Client, ClientInterfaceHandler, SimpleClientInterfaceHandler |
| 60 |
from .error import ( |
| 61 |
InterfaceNotFound, |
| 62 |
InvalidParameter, |
| 63 |
MethodNotFound, |
| 64 |
MethodNotImplemented, |
| 65 |
VarlinkEncoder, |
| 66 |
VarlinkError, |
| 67 |
) |
| 68 |
from .scanner import Interface, Scanner |
| 69 |
from .server import RequestHandler, Server, Service, ThreadingServer, get_listen_fd |
| 70 |
|
| 71 |
|
| 72 |
# There are no tests here, so don't try to run anything discovered from |
| 73 |
# introspecting the symbols (e.g. FunctionTestCase). Instead, all our |
| 74 |
# tests come from within varlink.tests. |
| 75 |
def load_tests(loader, tests, pattern): |
| 76 |
import os.path |
| 77 |
import sys |
| 78 |
from fnmatch import fnmatch |
| 79 |
|
| 80 |
if pattern is None: |
| 81 |
pattern = "test_*.py" |
| 82 |
|
| 83 |
# top level directory cached on loader instance |
| 84 |
test_dir = os.path.dirname(__file__) + "/tests" |
| 85 |
for fn in os.listdir(test_dir): |
| 86 |
if fnmatch(fn, pattern): |
| 87 |
modname = "varlink.tests." + fn[:-3] |
| 88 |
__import__(modname) |
| 89 |
module = sys.modules[modname] |
| 90 |
tests.addTest(loader.loadTestsFromModule(module)) |
| 91 |
return tests |