dbus-fast 3.0.0__cp314-cp314-musllinux_1_2_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dbus-fast might be problematic. Click here for more details.
- dbus_fast/__init__.py +82 -0
- dbus_fast/__version__.py +10 -0
- dbus_fast/_private/__init__.py +1 -0
- dbus_fast/_private/_cython_compat.py +14 -0
- dbus_fast/_private/address.cpython-314-aarch64-linux-musl.so +0 -0
- dbus_fast/_private/address.pxd +15 -0
- dbus_fast/_private/address.py +119 -0
- dbus_fast/_private/constants.py +20 -0
- dbus_fast/_private/marshaller.cpython-314-aarch64-linux-musl.so +0 -0
- dbus_fast/_private/marshaller.pxd +110 -0
- dbus_fast/_private/marshaller.py +231 -0
- dbus_fast/_private/unmarshaller.cpython-314-aarch64-linux-musl.so +0 -0
- dbus_fast/_private/unmarshaller.pxd +261 -0
- dbus_fast/_private/unmarshaller.py +904 -0
- dbus_fast/_private/util.py +177 -0
- dbus_fast/aio/__init__.py +5 -0
- dbus_fast/aio/message_bus.py +569 -0
- dbus_fast/aio/message_reader.cpython-314-aarch64-linux-musl.so +0 -0
- dbus_fast/aio/message_reader.pxd +13 -0
- dbus_fast/aio/message_reader.py +51 -0
- dbus_fast/aio/proxy_object.py +207 -0
- dbus_fast/auth.py +125 -0
- dbus_fast/constants.py +152 -0
- dbus_fast/errors.py +81 -0
- dbus_fast/glib/__init__.py +3 -0
- dbus_fast/glib/message_bus.py +513 -0
- dbus_fast/glib/proxy_object.py +318 -0
- dbus_fast/introspection.py +682 -0
- dbus_fast/message.cpython-314-aarch64-linux-musl.so +0 -0
- dbus_fast/message.pxd +76 -0
- dbus_fast/message.py +389 -0
- dbus_fast/message_bus.cpython-314-aarch64-linux-musl.so +0 -0
- dbus_fast/message_bus.pxd +75 -0
- dbus_fast/message_bus.py +1332 -0
- dbus_fast/proxy_object.py +357 -0
- dbus_fast/py.typed +0 -0
- dbus_fast/send_reply.py +61 -0
- dbus_fast/service.cpython-314-aarch64-linux-musl.so +0 -0
- dbus_fast/service.pxd +50 -0
- dbus_fast/service.py +701 -0
- dbus_fast/signature.cpython-314-aarch64-linux-musl.so +0 -0
- dbus_fast/signature.pxd +31 -0
- dbus_fast/signature.py +484 -0
- dbus_fast/unpack.cpython-314-aarch64-linux-musl.so +0 -0
- dbus_fast/unpack.pxd +13 -0
- dbus_fast/unpack.py +28 -0
- dbus_fast/validators.py +199 -0
- dbus_fast-3.0.0.dist-info/METADATA +262 -0
- dbus_fast-3.0.0.dist-info/RECORD +51 -0
- dbus_fast-3.0.0.dist-info/WHEEL +4 -0
- dbus_fast-3.0.0.dist-info/licenses/LICENSE +22 -0
dbus_fast/validators.py
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from functools import lru_cache
|
|
3
|
+
|
|
4
|
+
from .errors import (
|
|
5
|
+
InvalidBusNameError,
|
|
6
|
+
InvalidInterfaceNameError,
|
|
7
|
+
InvalidMemberNameError,
|
|
8
|
+
InvalidObjectPathError,
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
_bus_name_re = re.compile(r"^[A-Za-z_-][A-Za-z0-9_-]*$")
|
|
12
|
+
_path_re = re.compile(r"^[A-Za-z0-9_]+$")
|
|
13
|
+
_element_re = re.compile(r"^[A-Za-z_][A-Za-z0-9_]*$")
|
|
14
|
+
_member_re = re.compile(r"^[A-Za-z_][A-Za-z0-9_-]*$")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@lru_cache(maxsize=32)
|
|
18
|
+
def is_bus_name_valid(name: str) -> bool:
|
|
19
|
+
"""Whether this is a valid bus name.
|
|
20
|
+
|
|
21
|
+
.. seealso:: https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus
|
|
22
|
+
|
|
23
|
+
:param name: The bus name to validate.
|
|
24
|
+
:type name: str
|
|
25
|
+
|
|
26
|
+
:returns: Whether the name is a valid bus name.
|
|
27
|
+
:rtype: bool
|
|
28
|
+
"""
|
|
29
|
+
if not isinstance(name, str):
|
|
30
|
+
return False # type: ignore[unreachable]
|
|
31
|
+
|
|
32
|
+
if not name or len(name) > 255:
|
|
33
|
+
return False
|
|
34
|
+
|
|
35
|
+
if name.startswith(":"):
|
|
36
|
+
# a unique bus name
|
|
37
|
+
return True
|
|
38
|
+
|
|
39
|
+
if name.startswith("."):
|
|
40
|
+
return False
|
|
41
|
+
|
|
42
|
+
if name.find(".") == -1:
|
|
43
|
+
return False
|
|
44
|
+
|
|
45
|
+
for element in name.split("."):
|
|
46
|
+
if _bus_name_re.search(element) is None:
|
|
47
|
+
return False
|
|
48
|
+
|
|
49
|
+
return True
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@lru_cache(maxsize=1024)
|
|
53
|
+
def is_object_path_valid(path: str) -> bool:
|
|
54
|
+
"""Whether this is a valid object path.
|
|
55
|
+
|
|
56
|
+
.. seealso:: https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-object-path
|
|
57
|
+
|
|
58
|
+
:param path: The object path to validate.
|
|
59
|
+
:type path: str
|
|
60
|
+
|
|
61
|
+
:returns: Whether the object path is valid.
|
|
62
|
+
:rtype: bool
|
|
63
|
+
"""
|
|
64
|
+
if not isinstance(path, str):
|
|
65
|
+
return False # type: ignore[unreachable]
|
|
66
|
+
|
|
67
|
+
if not path:
|
|
68
|
+
return False
|
|
69
|
+
|
|
70
|
+
if not path.startswith("/"):
|
|
71
|
+
return False
|
|
72
|
+
|
|
73
|
+
if len(path) == 1:
|
|
74
|
+
return True
|
|
75
|
+
|
|
76
|
+
for element in path[1:].split("/"):
|
|
77
|
+
if _path_re.search(element) is None:
|
|
78
|
+
return False
|
|
79
|
+
|
|
80
|
+
return True
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@lru_cache(maxsize=32)
|
|
84
|
+
def is_interface_name_valid(name: str) -> bool:
|
|
85
|
+
"""Whether this is a valid interface name.
|
|
86
|
+
|
|
87
|
+
.. seealso:: https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-interface
|
|
88
|
+
|
|
89
|
+
:param name: The interface name to validate.
|
|
90
|
+
:type name: str
|
|
91
|
+
|
|
92
|
+
:returns: Whether the name is a valid interface name.
|
|
93
|
+
:rtype: bool
|
|
94
|
+
"""
|
|
95
|
+
if not isinstance(name, str):
|
|
96
|
+
return False # type: ignore[unreachable]
|
|
97
|
+
|
|
98
|
+
if not name or len(name) > 255:
|
|
99
|
+
return False
|
|
100
|
+
|
|
101
|
+
if name.startswith("."):
|
|
102
|
+
return False
|
|
103
|
+
|
|
104
|
+
if name.find(".") == -1:
|
|
105
|
+
return False
|
|
106
|
+
|
|
107
|
+
for element in name.split("."):
|
|
108
|
+
if _element_re.search(element) is None:
|
|
109
|
+
return False
|
|
110
|
+
|
|
111
|
+
return True
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@lru_cache(maxsize=512)
|
|
115
|
+
def is_member_name_valid(member: str) -> bool:
|
|
116
|
+
"""Whether this is a valid member name.
|
|
117
|
+
|
|
118
|
+
.. seealso:: https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-member
|
|
119
|
+
|
|
120
|
+
:param member: The member name to validate.
|
|
121
|
+
:type member: str
|
|
122
|
+
|
|
123
|
+
:returns: Whether the name is a valid member name.
|
|
124
|
+
:rtype: bool
|
|
125
|
+
"""
|
|
126
|
+
if not isinstance(member, str):
|
|
127
|
+
return False # type: ignore[unreachable]
|
|
128
|
+
|
|
129
|
+
if not member or len(member) > 255:
|
|
130
|
+
return False
|
|
131
|
+
|
|
132
|
+
if _member_re.search(member) is None:
|
|
133
|
+
return False
|
|
134
|
+
|
|
135
|
+
return True
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
@lru_cache(maxsize=32)
|
|
139
|
+
def assert_bus_name_valid(name: str) -> None:
|
|
140
|
+
"""Raise an error if this is not a valid bus name.
|
|
141
|
+
|
|
142
|
+
.. seealso:: https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus
|
|
143
|
+
|
|
144
|
+
:param name: The bus name to validate.
|
|
145
|
+
:type name: str
|
|
146
|
+
|
|
147
|
+
:raises:
|
|
148
|
+
- :class:`InvalidBusNameError` - If this is not a valid bus name.
|
|
149
|
+
"""
|
|
150
|
+
if not is_bus_name_valid(name):
|
|
151
|
+
raise InvalidBusNameError(name)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@lru_cache(maxsize=1024)
|
|
155
|
+
def assert_object_path_valid(path: str) -> None:
|
|
156
|
+
"""Raise an error if this is not a valid object path.
|
|
157
|
+
|
|
158
|
+
.. seealso:: https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-object-path
|
|
159
|
+
|
|
160
|
+
:param path: The object path to validate.
|
|
161
|
+
:type path: str
|
|
162
|
+
|
|
163
|
+
:raises:
|
|
164
|
+
- :class:`InvalidObjectPathError` - If this is not a valid object path.
|
|
165
|
+
"""
|
|
166
|
+
if not is_object_path_valid(path):
|
|
167
|
+
raise InvalidObjectPathError(path)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
@lru_cache(maxsize=32)
|
|
171
|
+
def assert_interface_name_valid(name: str) -> None:
|
|
172
|
+
"""Raise an error if this is not a valid interface name.
|
|
173
|
+
|
|
174
|
+
.. seealso:: https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-interface
|
|
175
|
+
|
|
176
|
+
:param name: The interface name to validate.
|
|
177
|
+
:type name: str
|
|
178
|
+
|
|
179
|
+
:raises:
|
|
180
|
+
- :class:`InvalidInterfaceNameError` - If this is not a valid object path.
|
|
181
|
+
"""
|
|
182
|
+
if not is_interface_name_valid(name):
|
|
183
|
+
raise InvalidInterfaceNameError(name)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
@lru_cache(maxsize=512)
|
|
187
|
+
def assert_member_name_valid(member: str) -> None:
|
|
188
|
+
"""Raise an error if this is not a valid member name.
|
|
189
|
+
|
|
190
|
+
.. seealso:: https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-member
|
|
191
|
+
|
|
192
|
+
:param member: The member name to validate.
|
|
193
|
+
:type member: str
|
|
194
|
+
|
|
195
|
+
:raises:
|
|
196
|
+
- :class:`InvalidMemberNameError` - If this is not a valid object path.
|
|
197
|
+
"""
|
|
198
|
+
if not is_member_name_valid(member):
|
|
199
|
+
raise InvalidMemberNameError(member)
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dbus-fast
|
|
3
|
+
Version: 3.0.0
|
|
4
|
+
Summary: A faster version of dbus-next
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Author: Bluetooth Devices Authors
|
|
8
|
+
Author-email: bluetooth@koston.org
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
22
|
+
Project-URL: Bug Tracker, https://github.com/bluetooth-devices/dbus-fast/issues
|
|
23
|
+
Project-URL: Changelog, https://github.com/bluetooth-devices/dbus-fast/blob/main/CHANGELOG.md
|
|
24
|
+
Project-URL: Documentation, https://dbus-fast.readthedocs.io
|
|
25
|
+
Project-URL: Repository, https://github.com/bluetooth-devices/dbus-fast
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# dbus-fast
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<a href="https://github.com/bluetooth-devices/dbus-fast/actions?query=workflow%3ACI">
|
|
32
|
+
<img src="https://img.shields.io/github/workflow/status/bluetooth-devices/dbus-fast/CI/main?label=CI&logo=github&style=flat-square" alt="CI Status" >
|
|
33
|
+
</a>
|
|
34
|
+
<a href="https://dbus-fast.readthedocs.io">
|
|
35
|
+
<img src="https://img.shields.io/readthedocs/dbus-fast.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">
|
|
36
|
+
</a>
|
|
37
|
+
<a href="https://codecov.io/gh/bluetooth-devices/dbus-fast">
|
|
38
|
+
<img src="https://img.shields.io/codecov/c/github/bluetooth-devices/dbus-fast.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
|
|
39
|
+
</a>
|
|
40
|
+
</p>
|
|
41
|
+
<p align="center">
|
|
42
|
+
<a href="https://python-poetry.org/">
|
|
43
|
+
<img src="https://img.shields.io/badge/packaging-poetry-299bd7?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAASCAYAAABrXO8xAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAJJSURBVHgBfZLPa1NBEMe/s7tNXoxW1KJQKaUHkXhQvHgW6UHQQ09CBS/6V3hKc/AP8CqCrUcpmop3Cx48eDB4yEECjVQrlZb80CRN8t6OM/teagVxYZi38+Yz853dJbzoMV3MM8cJUcLMSUKIE8AzQ2PieZzFxEJOHMOgMQQ+dUgSAckNXhapU/NMhDSWLs1B24A8sO1xrN4NECkcAC9ASkiIJc6k5TRiUDPhnyMMdhKc+Zx19l6SgyeW76BEONY9exVQMzKExGKwwPsCzza7KGSSWRWEQhyEaDXp6ZHEr416ygbiKYOd7TEWvvcQIeusHYMJGhTwF9y7sGnSwaWyFAiyoxzqW0PM/RjghPxF2pWReAowTEXnDh0xgcLs8l2YQmOrj3N7ByiqEoH0cARs4u78WgAVkoEDIDoOi3AkcLOHU60RIg5wC4ZuTC7FaHKQm8Hq1fQuSOBvX/sodmNJSB5geaF5CPIkUeecdMxieoRO5jz9bheL6/tXjrwCyX/UYBUcjCaWHljx1xiX6z9xEjkYAzbGVnB8pvLmyXm9ep+W8CmsSHQQY77Zx1zboxAV0w7ybMhQmfqdmmw3nEp1I0Z+FGO6M8LZdoyZnuzzBdjISicKRnpxzI9fPb+0oYXsNdyi+d3h9bm9MWYHFtPeIZfLwzmFDKy1ai3p+PDls1Llz4yyFpferxjnyjJDSEy9CaCx5m2cJPerq6Xm34eTrZt3PqxYO1XOwDYZrFlH1fWnpU38Y9HRze3lj0vOujZcXKuuXm3jP+s3KbZVra7y2EAAAAAASUVORK5CYII=" alt="Poetry">
|
|
44
|
+
</a>
|
|
45
|
+
<a href="https://github.com/astral-sh/ruff">
|
|
46
|
+
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff">
|
|
47
|
+
</a>
|
|
48
|
+
<a href="https://github.com/pre-commit/pre-commit">
|
|
49
|
+
<img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" alt="pre-commit">
|
|
50
|
+
</a>
|
|
51
|
+
<a href="https://codspeed.io/Bluetooth-Devices/dbus-fast"><img src="https://img.shields.io/endpoint?url=https://codspeed.io/badge.json" alt="CodSpeed Badge"/></a>
|
|
52
|
+
</p>
|
|
53
|
+
<p align="center">
|
|
54
|
+
<a href="https://pypi.org/project/dbus-fast/">
|
|
55
|
+
<img src="https://img.shields.io/pypi/v/dbus-fast.svg?logo=python&logoColor=fff&style=flat-square" alt="PyPI Version">
|
|
56
|
+
</a>
|
|
57
|
+
<img src="https://img.shields.io/pypi/pyversions/dbus-fast.svg?style=flat-square&logo=python&logoColor=fff" alt="Supported Python versions">
|
|
58
|
+
<img src="https://img.shields.io/pypi/l/dbus-fast.svg?style=flat-square" alt="License">
|
|
59
|
+
</p>
|
|
60
|
+
|
|
61
|
+
A faster version of dbus-next originally from the [great DBus next library](https://github.com/altdesktop/python-dbus-next) ❤️
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
Install this via pip (or your favourite package manager):
|
|
66
|
+
|
|
67
|
+
`pip install dbus-fast`
|
|
68
|
+
|
|
69
|
+
[Documentation](https://dbus-fast.readthedocs.io/en/latest/)
|
|
70
|
+
|
|
71
|
+
dbus-fast is a Python library for DBus that aims to be a performant fully featured high level library primarily geared towards integration of applications into Linux desktop and mobile environments.
|
|
72
|
+
|
|
73
|
+
Desktop application developers can use this library for integrating their applications into desktop environments by implementing common DBus standard interfaces or creating custom plugin interfaces.
|
|
74
|
+
|
|
75
|
+
Desktop users can use this library to create their own scripts and utilities to interact with those interfaces for customization of their desktop environment.
|
|
76
|
+
|
|
77
|
+
dbus-fast plans to improve over other DBus libraries for Python in the following ways:
|
|
78
|
+
|
|
79
|
+
- Zero dependencies and pure Python 3
|
|
80
|
+
- An optional cython extension is available to speed up (un)marshalling
|
|
81
|
+
- Focus on performance
|
|
82
|
+
- Support for multiple IO backends including asyncio and the GLib main loop.
|
|
83
|
+
- Nonblocking IO suitable for GUI development.
|
|
84
|
+
- Target the latest language features of Python for beautiful services and clients.
|
|
85
|
+
- Complete implementation of the DBus type system without ever guessing types.
|
|
86
|
+
- Integration tests for all features of the library.
|
|
87
|
+
- Completely documented public API.
|
|
88
|
+
|
|
89
|
+
## Installing
|
|
90
|
+
|
|
91
|
+
This library is available on PyPi as [dbus-fast](https://pypi.org/project/dbus-fast/).
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
pip3 install dbus-fast
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## The Client Interface
|
|
98
|
+
|
|
99
|
+
To use a service on the bus, the library constructs a proxy object you can use to call methods, get and set properties, and listen to signals.
|
|
100
|
+
|
|
101
|
+
For more information, see the [overview for the high-level client](https://dbus-fast.readthedocs.io/en/latest/high-level-client/index.html).
|
|
102
|
+
|
|
103
|
+
This example connects to a media player and controls it with the [MPRIS](https://specifications.freedesktop.org/mpris-spec/latest/) DBus interface.
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from dbus_fast.aio import MessageBus
|
|
107
|
+
|
|
108
|
+
import asyncio
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
async def main():
|
|
112
|
+
bus = await MessageBus().connect()
|
|
113
|
+
# the introspection xml would normally be included in your project, but
|
|
114
|
+
# this is convenient for development
|
|
115
|
+
introspection = await bus.introspect('org.mpris.MediaPlayer2.vlc', '/org/mpris/MediaPlayer2')
|
|
116
|
+
|
|
117
|
+
obj = bus.get_proxy_object('org.mpris.MediaPlayer2.vlc', '/org/mpris/MediaPlayer2', introspection)
|
|
118
|
+
player = obj.get_interface('org.mpris.MediaPlayer2.Player')
|
|
119
|
+
properties = obj.get_interface('org.freedesktop.DBus.Properties')
|
|
120
|
+
|
|
121
|
+
# call methods on the interface (this causes the media player to play)
|
|
122
|
+
await player.call_play()
|
|
123
|
+
|
|
124
|
+
volume = await player.get_volume()
|
|
125
|
+
print(f'current volume: {volume}, setting to 0.5')
|
|
126
|
+
|
|
127
|
+
await player.set_volume(0.5)
|
|
128
|
+
|
|
129
|
+
# listen to signals
|
|
130
|
+
def on_properties_changed(interface_name, changed_properties, invalidated_properties):
|
|
131
|
+
for changed, variant in changed_properties.items():
|
|
132
|
+
print(f'property changed: {changed} - {variant.value}')
|
|
133
|
+
|
|
134
|
+
properties.on_properties_changed(on_properties_changed)
|
|
135
|
+
|
|
136
|
+
await asyncio.Event().wait()
|
|
137
|
+
|
|
138
|
+
asyncio.run(main())
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## The Service Interface
|
|
142
|
+
|
|
143
|
+
To define a service on the bus, use the `ServiceInterface` class and decorate class methods to specify DBus methods, properties, and signals with their type signatures.
|
|
144
|
+
|
|
145
|
+
For more information, see the [overview for the high-level service](https://dbus-fast.readthedocs.io/en/latest/high-level-service/index.html).
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from dbus_fast.service import ServiceInterface, method, dbus_property, signal, Variant
|
|
149
|
+
from dbus_fast.aio MessageBus
|
|
150
|
+
|
|
151
|
+
import asyncio
|
|
152
|
+
|
|
153
|
+
class ExampleInterface(ServiceInterface):
|
|
154
|
+
def __init__(self, name):
|
|
155
|
+
super().__init__(name)
|
|
156
|
+
self._string_prop = 'kevin'
|
|
157
|
+
|
|
158
|
+
@dbus_method()
|
|
159
|
+
def Echo(self, what: 's') -> 's':
|
|
160
|
+
return what
|
|
161
|
+
|
|
162
|
+
@dbus_method()
|
|
163
|
+
def GetVariantDict() -> 'a{sv}':
|
|
164
|
+
return {
|
|
165
|
+
'foo': Variant('s', 'bar'),
|
|
166
|
+
'bat': Variant('x', -55),
|
|
167
|
+
'a_list': Variant('as', ['hello', 'world'])
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@dbus_property()
|
|
171
|
+
def string_prop(self) -> 's':
|
|
172
|
+
return self._string_prop
|
|
173
|
+
|
|
174
|
+
@string_prop.setter
|
|
175
|
+
def string_prop_setter(self, val: 's'):
|
|
176
|
+
self._string_prop = val
|
|
177
|
+
|
|
178
|
+
@dbus_signal()
|
|
179
|
+
def signal_simple(self) -> 's':
|
|
180
|
+
return 'hello'
|
|
181
|
+
|
|
182
|
+
async def main():
|
|
183
|
+
bus = await MessageBus().connect()
|
|
184
|
+
interface = ExampleInterface('test.interface')
|
|
185
|
+
bus.export('/test/path', interface)
|
|
186
|
+
# now that we are ready to handle requests, we can request name from D-Bus
|
|
187
|
+
await bus.request_name('test.name')
|
|
188
|
+
# wait indefinitely
|
|
189
|
+
await asyncio.Event().wait()
|
|
190
|
+
|
|
191
|
+
asyncio.run(main())
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## The Low-Level Interface
|
|
195
|
+
|
|
196
|
+
The low-level interface works with DBus messages directly.
|
|
197
|
+
|
|
198
|
+
For more information, see the [overview for the low-level interface](https://dbus-fast.readthedocs.io/en/latest/low-level-interface/index.html).
|
|
199
|
+
|
|
200
|
+
```python
|
|
201
|
+
from dbus_fast.message import Message, MessageType
|
|
202
|
+
from dbus_fast.aio import MessageBus
|
|
203
|
+
|
|
204
|
+
import asyncio
|
|
205
|
+
import json
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
async def main():
|
|
209
|
+
bus = await MessageBus().connect()
|
|
210
|
+
|
|
211
|
+
reply = await bus.call(
|
|
212
|
+
Message(destination='org.freedesktop.DBus',
|
|
213
|
+
path='/org/freedesktop/DBus',
|
|
214
|
+
interface='org.freedesktop.DBus',
|
|
215
|
+
member='ListNames'))
|
|
216
|
+
|
|
217
|
+
if reply.message_type == MessageType.ERROR:
|
|
218
|
+
raise Exception(reply.body[0])
|
|
219
|
+
|
|
220
|
+
print(json.dumps(reply.body[0], indent=2))
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
asyncio.run(main())
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Projects that use dbus-fast
|
|
227
|
+
|
|
228
|
+
- [Bluetooth Adapters](https://github.com/bluetooth-devices/bluetooth-adapters)
|
|
229
|
+
|
|
230
|
+
## Contributing
|
|
231
|
+
|
|
232
|
+
Contributions are welcome. Development happens on [Github](https://github.com/Bluetooth-Devices/dbus-fast).
|
|
233
|
+
|
|
234
|
+
Before you commit, run `pre-commit run --all-files` to run the linter, code formatter, and the test suite.
|
|
235
|
+
|
|
236
|
+
## Copyright
|
|
237
|
+
|
|
238
|
+
You can use this code under an MIT license (see LICENSE).
|
|
239
|
+
|
|
240
|
+
- © 2019, Tony Crisci
|
|
241
|
+
- © 2022, Bluetooth Devices authors
|
|
242
|
+
|
|
243
|
+
## Contributors ✨
|
|
244
|
+
|
|
245
|
+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
|
|
246
|
+
|
|
247
|
+
<!-- prettier-ignore-start -->
|
|
248
|
+
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
249
|
+
<!-- markdownlint-disable -->
|
|
250
|
+
<!-- markdownlint-enable -->
|
|
251
|
+
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
252
|
+
<!-- prettier-ignore-end -->
|
|
253
|
+
|
|
254
|
+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
|
255
|
+
|
|
256
|
+
## Credits
|
|
257
|
+
|
|
258
|
+
This package was created with
|
|
259
|
+
[Cookiecutter](https://github.com/audreyr/cookiecutter) and the
|
|
260
|
+
[browniebroke/cookiecutter-pypackage](https://github.com/browniebroke/cookiecutter-pypackage)
|
|
261
|
+
project template.
|
|
262
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
dbus_fast/__init__.py,sha256=IYGz5EagZGOhz7TZf6kLXvDFHimOfcK3l2N0BO7e_-I,1948
|
|
2
|
+
dbus_fast/__version__.py,sha256=-3MzRj2QnbdjBjEQmEIfqI8QUcAdKrxVYMhse0jlE9E,400
|
|
3
|
+
dbus_fast/auth.py,sha256=1e7okKoYAnXOlYrfPPOo9-abcR6H-wwEo9HG9gpyfDk,4339
|
|
4
|
+
dbus_fast/constants.py,sha256=QdBdcT1Ga3BfE_ox1TWERftxALO5os8nZuneh_wfMso,6066
|
|
5
|
+
dbus_fast/errors.py,sha256=iWV8k-sh5-JtREv7TtQTAuSPSSIP1-LpVKmFk8ZrrbA,1978
|
|
6
|
+
dbus_fast/introspection.py,sha256=pLozNsHnAKD3UDJoLftC9K5wDxQSDTavxjLJO9eG5Aw,25588
|
|
7
|
+
dbus_fast/message.cpython-314-aarch64-linux-musl.so,sha256=G9gMoj8Ks9Wtr3cnWnhRnASoKXntlkz6IdcYjgo7DA0,156848
|
|
8
|
+
dbus_fast/message.pxd,sha256=dDSRIDbgN3S3z7Fibv3Li-eQewk0pG98nLi_NoSyE2M,1831
|
|
9
|
+
dbus_fast/message.py,sha256=wq0vHSBy8VikE-MxiUuz-EFP2EPPa_I2wl_MIwlSYRs,13943
|
|
10
|
+
dbus_fast/message_bus.cpython-314-aarch64-linux-musl.so,sha256=Zd7Rwa5xVhxvDmi9ai_Sbrk4FLzhXgTQ0ZJE-WnuDJk,447960
|
|
11
|
+
dbus_fast/message_bus.pxd,sha256=BBhqvRh6qxszYCrQiqZOO2mUGjwlemW-HUXw-_YDL7Q,2078
|
|
12
|
+
dbus_fast/message_bus.py,sha256=xyZn-63fEFQQajr-RZZnhQF2iljfjEbpRV0kcuIFhoQ,49356
|
|
13
|
+
dbus_fast/proxy_object.py,sha256=Vf_HuQPNUJeZT3k-jOpBwwCf1hrfCK2f2vwO_MEFYvk,14616
|
|
14
|
+
dbus_fast/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
+
dbus_fast/send_reply.py,sha256=URk5Uot6JTRm_44SuM6kYmbW1r7e6oUnZHGc64DnEVs,1650
|
|
16
|
+
dbus_fast/service.cpython-314-aarch64-linux-musl.so,sha256=-N2OseNGa-3r0pdd1OXDTK7rpxhICv6wx6bf2uI_0-I,375200
|
|
17
|
+
dbus_fast/service.pxd,sha256=IjGbYRGVN0fJ6_Xbp--i1oCrVLBt87A2mAqxxHMSrJY,1177
|
|
18
|
+
dbus_fast/service.py,sha256=VEPGLxkkPZy8slhDOShg70lZxE1rwpnwPw_EpVmMcLk,25069
|
|
19
|
+
dbus_fast/signature.cpython-314-aarch64-linux-musl.so,sha256=Ff12jpQY3s3mhLqNxyP-JrYWRHdV5mcG0c4K0rasCzo,296320
|
|
20
|
+
dbus_fast/signature.pxd,sha256=o3O37zQiIm4HKsq6a42rHPyYIRQCEf6B10HkcVWL4K4,638
|
|
21
|
+
dbus_fast/signature.py,sha256=YOy0IMaf3JFU_7cK6tKyh0HHtEzKZO4jhEdlSjPEuC8,17772
|
|
22
|
+
dbus_fast/unpack.cpython-314-aarch64-linux-musl.so,sha256=oPEizJS_uxNxdqmuo_q8kgT7T4vtHH4voSgeJolJiL0,84672
|
|
23
|
+
dbus_fast/unpack.pxd,sha256=jwrWP1loFA5YT9DCNb0TZubJACJgckzuNZCXtlrgdB8,181
|
|
24
|
+
dbus_fast/unpack.py,sha256=9UR-crIQBiG-aV-5FC0R0JF8Do5Xv4vYFu4laXFHcJg,755
|
|
25
|
+
dbus_fast/validators.py,sha256=LId-6u87hhm7D4XGe3N_kSzX6rO5I9QRVTlHH8rdYbs,5239
|
|
26
|
+
dbus_fast/_private/__init__.py,sha256=U4S_2y3zgLZVfMenHRaJFBW8yqh2mUBuI291LGQVOJ8,35
|
|
27
|
+
dbus_fast/_private/_cython_compat.py,sha256=s0a49yrhvXeW9GwVI_Ubpsc-Xt0g_Ga_UQyo1Apgtm8,247
|
|
28
|
+
dbus_fast/_private/address.cpython-314-aarch64-linux-musl.so,sha256=A_7p7UxR9pdi7jW_liJl1qXcKEmNJiR7BQli5dVJS90,148864
|
|
29
|
+
dbus_fast/_private/address.pxd,sha256=1RKICTK01HOk253rRCqmgFCD3NDXXHbEKPyQvUIvtLU,287
|
|
30
|
+
dbus_fast/_private/address.py,sha256=blyt_R6bPrmxaySpeIO0nkp1mq3V8Yxf_FXQ2_6HWXg,4081
|
|
31
|
+
dbus_fast/_private/constants.py,sha256=-b2VrmSPLZnY1Bz-TipIRbYFDpa5IPtQ9uuErbJu8us,311
|
|
32
|
+
dbus_fast/_private/marshaller.cpython-314-aarch64-linux-musl.so,sha256=HOPDW3hdUCmzs29afA7AS2UicvYeGlaILMQt-Zdo4O4,222040
|
|
33
|
+
dbus_fast/_private/marshaller.pxd,sha256=WGpF4TFz7zHBO7XAmrT7aw0LSiM0T3bSvMvU-ju0bCc,2665
|
|
34
|
+
dbus_fast/_private/marshaller.py,sha256=r7v7nuL5LbvlFiFfck2qJU4QAMYn6KE5mqD6VHHC-DA,7866
|
|
35
|
+
dbus_fast/_private/unmarshaller.cpython-314-aarch64-linux-musl.so,sha256=tGq8EbJkc8idoM8voZdJJfhp31-BDQZRAC8tWNNN0lI,308984
|
|
36
|
+
dbus_fast/_private/unmarshaller.pxd,sha256=sOvve73a-K0g6A0dxDPtPEGYF5gUqDHAl-SKuGxcr7M,7092
|
|
37
|
+
dbus_fast/_private/unmarshaller.py,sha256=Dj8-vL2QS_izbyTgDZoKAVGP3eU-04VtEf0YzmT0ziE,34305
|
|
38
|
+
dbus_fast/_private/util.py,sha256=du9qQyH_BW2rUnUnN5c6MpVbmI8aQM2oP-55FIW1y30,5997
|
|
39
|
+
dbus_fast/aio/__init__.py,sha256=GUbJM8P3joxXvv6TOE9ak45tiB1rJ-vjC9xXvk-8X3o,198
|
|
40
|
+
dbus_fast/aio/message_bus.py,sha256=jj9scvxef8VyYEkt5HPnrZL7hZPkfqO963A4yk7dwmY,20657
|
|
41
|
+
dbus_fast/aio/message_reader.cpython-314-aarch64-linux-musl.so,sha256=pfsmYQt1RwdMHpxlxN3857RYm4g50qiZxm-ut1k1k84,92384
|
|
42
|
+
dbus_fast/aio/message_reader.pxd,sha256=aC5SXPLJcaJ-UR0q1RLNZ5f4Q4qgJWH5FegT9xanJDo,226
|
|
43
|
+
dbus_fast/aio/message_reader.py,sha256=O1I8hkv7MZUT0Z63xubC4WdwnVzDybjz32pQWuxb1Uo,1721
|
|
44
|
+
dbus_fast/aio/proxy_object.py,sha256=yA4UUWS1uhqyQP8WemoI72CESHkqV9hMtTazmXonS5Y,7059
|
|
45
|
+
dbus_fast/glib/__init__.py,sha256=BOQBzyCC9spfx1m4uXv1oDaqDnAP8q-tasYdN5WWMpM,162
|
|
46
|
+
dbus_fast/glib/message_bus.py,sha256=3i8VTiF-vBRpkAZTLCiXKS7QDUcq_Veis8tkay_WpQ0,16420
|
|
47
|
+
dbus_fast/glib/proxy_object.py,sha256=GYT4ZeXV0-ROOrMxlvl3KeOdNw2bbdEUUklBB8OFO0A,10674
|
|
48
|
+
dbus_fast-3.0.0.dist-info/METADATA,sha256=c4RU0yjuycma3xBap_WJgyooN7A6GrPohn-S__DKMEU,10765
|
|
49
|
+
dbus_fast-3.0.0.dist-info/WHEEL,sha256=c_DzcancFUtfZSm9MgDmDQXwCENo1jyU7n_8ENwpCUk,110
|
|
50
|
+
dbus_fast-3.0.0.dist-info/RECORD,,
|
|
51
|
+
dbus_fast-3.0.0.dist-info/licenses/LICENSE,sha256=w36cdREOAdHwxTYNx9d3ajCsX3DSRA2yFEI-S3p3pq8,1083
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2022 Bluetooth Devices Authors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|