Skip to main content

A faster version of dbus-next

Project description

dbus-fast

CI Status Documentation Status Test coverage percentage

Poetry black pre-commit

PyPI Version Supported Python versions License

A faster version of dbus-next originally from the great DBus next library ❤️

Installation

Install this via pip (or your favourite package manager):

pip install dbus-fast

Documentation

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.

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.

Desktop users can use this library to create their own scripts and utilities to interact with those interfaces for customization of their desktop environment.

dbus-fast plans to improve over other DBus libraries for Python in the following ways:

  • Zero dependencies and pure Python 3
  • An optional cython extension is available to speed up (un)marshalling
  • Focus on performance
  • Support for multiple IO backends including asyncio and the GLib main loop.
  • Nonblocking IO suitable for GUI development.
  • Target the latest language features of Python for beautiful services and clients.
  • Complete implementation of the DBus type system without ever guessing types.
  • Integration tests for all features of the library.
  • Completely documented public API.

Installing

This library is available on PyPi as dbus-fast.

pip3 install dbus-fast

The Client Interface

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.

For more information, see the overview for the high-level client.

This example connects to a media player and controls it with the MPRIS DBus interface.

from dbus_fast.aio import MessageBus

import asyncio


async def main():
    bus = await MessageBus().connect()
    # the introspection xml would normally be included in your project, but
    # this is convenient for development
    introspection = await bus.introspect('org.mpris.MediaPlayer2.vlc', '/org/mpris/MediaPlayer2')

    obj = bus.get_proxy_object('org.mpris.MediaPlayer2.vlc', '/org/mpris/MediaPlayer2', introspection)
    player = obj.get_interface('org.mpris.MediaPlayer2.Player')
    properties = obj.get_interface('org.freedesktop.DBus.Properties')

    # call methods on the interface (this causes the media player to play)
    await player.call_play()

    volume = await player.get_volume()
    print(f'current volume: {volume}, setting to 0.5')

    await player.set_volume(0.5)

    # listen to signals
    def on_properties_changed(interface_name, changed_properties, invalidated_properties):
        for changed, variant in changed_properties.items():
            print(f'property changed: {changed} - {variant.value}')

    properties.on_properties_changed(on_properties_changed)

    await asyncio.Event().wait()

asyncio.run(main())

The Service Interface

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.

For more information, see the overview for the high-level service.

from dbus_fast.service import ServiceInterface, method, dbus_property, signal, Variant
from dbus_fast.aio MessageBus

import asyncio

class ExampleInterface(ServiceInterface):
    def __init__(self, name):
        super().__init__(name)
        self._string_prop = 'kevin'

    @method()
    def Echo(self, what: 's') -> 's':
        return what

    @method()
    def GetVariantDict() -> 'a{sv}':
        return {
            'foo': Variant('s', 'bar'),
            'bat': Variant('x', -55),
            'a_list': Variant('as', ['hello', 'world'])
        }

    @dbus_property()
    def string_prop(self) -> 's':
        return self._string_prop

    @string_prop.setter
    def string_prop_setter(self, val: 's'):
        self._string_prop = val

    @signal()
    def signal_simple(self) -> 's':
        return 'hello'

async def main():
    bus = await MessageBus().connect()
    interface = ExampleInterface('test.interface')
    bus.export('/test/path', interface)
    # now that we are ready to handle requests, we can request name from D-Bus
    await bus.request_name('test.name')
    # wait indefinitely
    await asyncio.Event().wait()

asyncio.run(main())

The Low-Level Interface

The low-level interface works with DBus messages directly.

For more information, see the overview for the low-level interface.

from dbus_fast.message import Message, MessageType
from dbus_fast.aio import MessageBus

import asyncio
import json


async def main():
    bus = await MessageBus().connect()

    reply = await bus.call(
        Message(destination='org.freedesktop.DBus',
                path='/org/freedesktop/DBus',
                interface='org.freedesktop.DBus',
                member='ListNames'))

    if reply.message_type == MessageType.ERROR:
        raise Exception(reply.body[0])

    print(json.dumps(reply.body[0], indent=2))


asyncio.run(main())

Projects that use python-dbus-fast

Contributing

Contributions are welcome. Development happens on Github.

Before you commit, run pre-commit run --all-files to run the linter, code formatter, and the test suite.

Copyright

You can use this code under an MIT license (see LICENSE).

  • © 2019, Tony Crisci
  • © 2022, Bluetooth Devices authors

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Credits

This package was created with Cookiecutter and the browniebroke/cookiecutter-pypackage project template.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbus_fast-1.40.0.tar.gz (62.1 kB view details)

Uploaded Source

Built Distributions

dbus_fast-1.40.0-cp311-cp311-musllinux_1_1_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

dbus_fast-1.40.0-cp311-cp311-musllinux_1_1_i686.whl (2.2 MB view details)

Uploaded CPython 3.11 musllinux: musl 1.1+ i686

dbus_fast-1.40.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

dbus_fast-1.40.0-cp311-cp311-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl (2.1 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dbus_fast-1.40.0-cp310-cp310-musllinux_1_1_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

dbus_fast-1.40.0-cp310-cp310-musllinux_1_1_i686.whl (2.2 MB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

dbus_fast-1.40.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

dbus_fast-1.40.0-cp310-cp310-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl (2.1 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dbus_fast-1.40.0-cp39-cp39-manylinux_2_31_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.31+ x86-64

dbus_fast-1.40.0-cp39-cp39-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl (2.1 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dbus_fast-1.40.0-cp38-cp38-musllinux_1_1_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

dbus_fast-1.40.0-cp38-cp38-musllinux_1_1_i686.whl (2.2 MB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

dbus_fast-1.40.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

dbus_fast-1.40.0-cp38-cp38-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl (2.1 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

dbus_fast-1.40.0-cp37-cp37m-musllinux_1_1_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

dbus_fast-1.40.0-cp37-cp37m-musllinux_1_1_i686.whl (1.9 MB view details)

Uploaded CPython 3.7m musllinux: musl 1.1+ i686

dbus_fast-1.40.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

dbus_fast-1.40.0-cp37-cp37m-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl (1.9 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686 manylinux: glibc 2.5+ i686

File details

Details for the file dbus_fast-1.40.0.tar.gz.

File metadata

  • Download URL: dbus_fast-1.40.0.tar.gz
  • Upload date:
  • Size: 62.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.2 requests/2.28.1 requests-toolbelt/0.10.0 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/5.0.0 keyring/23.9.3 rfc3986/2.0.0 colorama/0.4.5 CPython/3.9.14

File hashes

Hashes for dbus_fast-1.40.0.tar.gz
Algorithm Hash digest
SHA256 9c96934b091b85508aa3c9c006edf4a86f14d83908e0c1066a580d8e9d1b486d
MD5 980d4dd93c5ed4d98cf1a81db1e6ced9
BLAKE2b-256 5fe807c568f2e210fb12e3ef13f866c4ced189d83d39ab1724b7b9a244f2a25f

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp311-cp311-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 c5df91fed7b6acfaba9c70dc8884d4fde51fe8e9f8c3fc41bd7027528d917466
MD5 65c8e694882d7d18dd6d24edf7b34a76
BLAKE2b-256 df397ecc5a834b3818d4107eb1de06c11123c6701d83053e915b8ed17f735514

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp311-cp311-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp311-cp311-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 9eb3f296aefc234fa4418c92f9f6bd2a3d5ed36ee163420b687d50610efecb5c
MD5 edbedbac981cf456f8f0fbce7985fc03
BLAKE2b-256 c1ab3952437e4ea3c5859798705a0096843fe2bce6f353e7d3bedc41aea1879c

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 12c71cbd03abee87ec81668de8e8979ca2a11aea69a82eead7b24d0e71f581ef
MD5 b40be56d853c0e9eecdf6386ea0d2b01
BLAKE2b-256 833e10ae732b78744d1d763e6c6348b41ffb649f6d3de98a1e0dca2dfc6df58e

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp311-cp311-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp311-cp311-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 13a8aa568aed799a01cb31d65f4e2c03b8b6b4291571369d87c067142bd9ab1e
MD5 15658f0e8b15fb3ebe58c51080e82a01
BLAKE2b-256 70e486975fd2aef88e3f666e7dabb5840eb9d0e27d1fcfa454c241b5d487466f

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 1ec3f370d5e533bdc3f8f30c2be300601c8815434843b6cd0d509e65ec9a649e
MD5 201744140da739e6353712d97e55b564
BLAKE2b-256 a40879ac985ba1bbf73b581e68c517e2c5a943813a423f249380fe1c37fefac2

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp310-cp310-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp310-cp310-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 dded4eeb295f2a932e6b4e52e48bf8ba2a42cf7aa6df5cf31f02389e8234fa22
MD5 c7c388432b604153e2aa6c1de03a093d
BLAKE2b-256 c97084aad090d41ab7f56151f824eeb3a99270087c46ed768f59f768b58a474c

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0f612c20d3edf3c8b11a6cbcff162dd0abc24d1508712949e5ea78175b5ec878
MD5 59dcdf0eea08013b15da44292aafb75c
BLAKE2b-256 48400430fedfd28bee8153805e8c2f6d737b7888d10543b07ed579fdf619fadb

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp310-cp310-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp310-cp310-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 0f513b1de6e4c70e2eb22f614813384af5844537d7b3997e8e55eba7b9b3c7ab
MD5 e708d580c03debd4bd1bdc1ed6b9c6e5
BLAKE2b-256 b823eddf51a0bb89a10ff8f7c1e5aac07d4fdb761bbe7309e9dfdeb98e74d589

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp39-cp39-manylinux_2_31_x86_64.whl.

File metadata

  • Download URL: dbus_fast-1.40.0-cp39-cp39-manylinux_2_31_x86_64.whl
  • Upload date:
  • Size: 2.1 MB
  • Tags: CPython 3.9, manylinux: glibc 2.31+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.3 readme-renderer/37.2 requests/2.28.1 requests-toolbelt/0.10.0 urllib3/1.26.12 tqdm/4.64.1 importlib-metadata/5.0.0 keyring/23.9.3 rfc3986/2.0.0 colorama/0.4.5 CPython/3.9.14

File hashes

Hashes for dbus_fast-1.40.0-cp39-cp39-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 f7bd9e68e4a2a714e34773ee919b8c6d162c681603751189cadb2b61e5979dd9
MD5 e0727d300aebae7a51ac8aca0d8eccfe
BLAKE2b-256 cd45af6d6b6a646ce4fb83565af18860db5d7b3df2a1d2d81c34681456e37aaf

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp39-cp39-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp39-cp39-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 65ef64e0ed4074304fdaf0c3360d7f0a0a9e415f43a097c321d179c1090421d2
MD5 45408df83871076c864c93c37b3fc33e
BLAKE2b-256 b63164762c8bac8ff39772203021e9951191e895d002924546642afd9f50f71b

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 f024567ffb2fc79d7b848624649b62d3302cc459d6ebcb395eeebeac28acd6e0
MD5 1883a668632299d3b4ab51030394acd7
BLAKE2b-256 83a32c5cae9569d679f0c87da86f337f9b184af47cb858f937db618f03516c57

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp38-cp38-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp38-cp38-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 a359b2266c717121d06d2bc04226401fe5dc2d1b9ea9b3a0431266668bad97ea
MD5 74f7a2f556fb8d346669eb4d6adcdeb9
BLAKE2b-256 a8ebd5e7d93e2cc50bdfb39f137031e71a1652029c529db09952412f8ecb5d3c

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e4e3791519e370073c14812c2e9ff6472842f1886be7ec5e83eead3126287798
MD5 f619165eb5d92fd64a45c68add34ba62
BLAKE2b-256 249cea8b4755dfd63d992a77bd6f41e8e18036b40e4ab5daba142ee21497b49f

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp38-cp38-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp38-cp38-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 9cfb74a7176b6e09eab80cb53babb73144c36bb9942e393b838670a1433671d0
MD5 56d2586bef6b54e4806bd9ac24fad22c
BLAKE2b-256 5438814dcc76dd6b0dfc55d2f02232f8487f5c0ba30a0202c6009db1af05bdc0

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp37-cp37m-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 c5771bef15a6dc64b2d0c80e0be2ccf80495c3fd917197fa74c1204c79f78846
MD5 d685ce296bf16ea396123edcc6ab9380
BLAKE2b-256 0f592c627631366477f2757f27170a069d09dd216730da224bacdee2b35a8d93

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp37-cp37m-musllinux_1_1_i686.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm Hash digest
SHA256 1a6143891c6d5487893b4076941c31ddb9eecc00aab0392acc3ed818a70f9654
MD5 c34486b7efb695ae9e949f8957480ff3
BLAKE2b-256 de42a8b4b6ffd340a31eddf11b1c33d5a4f253402f8d5fdb1980bc4c9e9831b5

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cd0cefea8e719919812ade09f42f13043f885dc1edb3ddb7b9fa71a365059fcd
MD5 a2cd23d9a21c6ea87281de97e79c91e2
BLAKE2b-256 a7d7e9d6bf009f6df09470e1d610b4213af478a08c5fb0941cbc9da5b6717a41

See more details on using hashes here.

File details

Details for the file dbus_fast-1.40.0-cp37-cp37m-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for dbus_fast-1.40.0-cp37-cp37m-manylinux_2_17_i686.manylinux_2_5_i686.manylinux1_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 a9ae57cfbf844afb8561263721601beb894558c5974759801f84ce8c405dfe25
MD5 f00808d6cef4227cb7a43dd4624ca2c6
BLAKE2b-256 6e867975c77a473cac76071b7905eca6c532c35c2b6ab10da323263317e2e273

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page