Closed Regela closed 1 year ago
This example doing that i need:
import asyncio
import sdbus
from sdbus import DbusInterfaceCommonAsync, dbus_property_async
# qdbus --literal --system org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.NetworkManager.ActiveConnections
class ListActiveInterface(DbusInterfaceCommonAsync,
interface_name='org.freedesktop.NetworkManager'
):
@dbus_property_async(
property_signature='aa{sv}',
property_name='ActiveConnections'
)
def active_connections(self) -> dict:
return {}
async def list_active_connections():
active_connections = ListActiveInterface.new_proxy('org.freedesktop.NetworkManager',
'/org/freedesktop/NetworkManager')
return await active_connections.active_connections
async def main():
print(await list_active_connections())
if __name__ == '__main__':
sdbus.set_default_bus(sdbus.sd_bus_open_system())
asyncio.run(main())
Sorry, i don't found it
from sdbus_async.networkmanager import NetworkManager
async def main():
nm = NetworkManager()
connections_paths: List[str] = await nm.active_connections
print(connections_paths)
Thank you for your library!
Yes, the nm.active_connections
property contains the list of all active connection object paths.
You probably want to initialize the active connection proxy objects.
active_connections = [ActiveConnection(x) for x in connections_paths]
@Regela BTW you should use the triple backtick ``` for code blocks.
Need possibility to get list ActiveConnections
bash sample:
How i can do it? Thanks