-
-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathdbus_proxy_async_interfaces.py
More file actions
111 lines (83 loc) · 3.28 KB
/
dbus_proxy_async_interfaces.py
File metadata and controls
111 lines (83 loc) · 3.28 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# SPDX-License-Identifier: LGPL-2.1-or-later
# Copyright (C) 2020-2024 igo95862
# This file is part of python-sdbus
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from __future__ import annotations
from typing import TYPE_CHECKING
from .dbus_common_funcs import _parse_properties_vardict
from .dbus_proxy_async_interface_base import DbusInterfaceBaseAsync
from .dbus_proxy_async_method import dbus_method_async
from .dbus_proxy_async_signal import dbus_signal_async
if TYPE_CHECKING:
from typing import Any, Literal
DBUS_PROPERTIES_CHANGED_TYPING = (
tuple[
str,
dict[str, tuple[str, Any]],
list[str],
]
)
class DbusPeerInterfaceAsync(
DbusInterfaceBaseAsync,
interface_name='org.freedesktop.DBus.Peer',
serving_enabled=False,
):
@dbus_method_async(method_name='Ping')
async def dbus_ping(self) -> None:
raise NotImplementedError
@dbus_method_async(method_name='GetMachineId')
async def dbus_machine_id(self) -> str:
raise NotImplementedError
class DbusIntrospectableAsync(
DbusInterfaceBaseAsync,
interface_name='org.freedesktop.DBus.Introspectable',
serving_enabled=False,
):
@dbus_method_async(method_name='Introspect')
async def dbus_introspect(self) -> str:
raise NotImplementedError
class DbusPropertiesInterfaceAsync(
DbusInterfaceBaseAsync,
interface_name='org.freedesktop.DBus.Properties',
serving_enabled=False,
):
@dbus_signal_async('sa{sv}as')
def properties_changed(self) -> DBUS_PROPERTIES_CHANGED_TYPING:
raise NotImplementedError
@dbus_method_async('s', 'a{sv}', method_name='GetAll')
async def _properties_get_all(
self, interface_name: str) -> dict[str, tuple[str, Any]]:
raise NotImplementedError
async def properties_get_all_dict(
self,
on_unknown_member: Literal['error', 'ignore', 'reuse'] = 'error',
) -> dict[str, Any]:
properties: dict[str, Any] = {}
for interface_name, meta in self._dbus_iter_interfaces_meta():
if not meta.serving_enabled:
continue
dbus_properties_data = await self._properties_get_all(
interface_name)
properties.update(
_parse_properties_vardict(
meta.dbus_member_to_python_attr,
dbus_properties_data,
on_unknown_member,
)
)
return properties
class DbusInterfaceCommonAsync(
DbusPropertiesInterfaceAsync,
DbusIntrospectableAsync,
DbusPeerInterfaceAsync):
...