Skip to main content

transforms values into properly wrapped dbus-python objects

Project description

Function

This library contains a function, make_class, that consumes an XML specification of a D-Bus interface.

>>> Klass = make_class("Klass", spec)

This call yields a Python class, called Klass, with two static class members, “Methods” and “Properties”. The “Methods” class has a static method corresponding to each method defined in the interface. Each method takes a proxy object as its first argument followed by any number of keyword arguments, corresponding to the arguments of the method. The “Properties” class has a static class corresponding to every property defined in the interface. Each property class may have a static Get() or Set() method, depending on its attributes.

For example, assuming the interface defines a read only Version property, the following call should return a value.

>>> Klass.Properties.Version.Get()

However, since Version is a read only property, the following call should fail with an AttributeError.

>>> Klass.Properties.Version.Set("42")

Similarly, if the interface defines a method, Create, with one argument, name, a STRING, the following call should succeed.

>>> Klass.Methods.Create(proxy, name="name")

The Create method invokes the method on the proxy object, passing force, transformed into a dbus-python String type.

On the other hand, the invocation will raise a DPClientError exception if the method is called with an argument with an incorrect type as,

>>> Klass.Methods.Create(proxy, name=false)

or with an incorrect keyword as,

>>> Klass.Methods.Create(proxy, force=false)

or without all the necessary keywords as,

>>> Klass.Methods.Create(proxy)

Errors

This library exports the exception type, DPClientError and all its subtypes. It constitutes a bug if an error of any other type is propagated during class generation or when the methods of the class are executed.

The following shows the error hierarchy. Entries after the dash indicate additional fields, beyond the message, which the exception contains. Only leaves of the error class hierarchy are constructed directly.

DPClientError

  • DPClientGenerationError This exception is raised if an error occurs while generating the method. Such an exception would result from introspection data which lacked the necessary attributes or entries.

  • DPClientRuntimeError - interface name This exception is raised if there is an error while the generated method is executing.

    • DPClientInvalidArgError This exception is raised if the arguments to be passed to the D-Bus method are incorrect.

      • DPClientKeywordError - method name, expected and actual keywords This exception is raised if there are missing or unexpected arguments.

      • DPClientMarshallingError - original arguments This exception is raised if the arguments can not be transformed to their required dbus-python types.

    • DPClientInvocationError - invocation context This exception is raised if a dbus-python method is invoked and some error occurs. This exception’s invocation context is used to distinguish between a method call, a get property call, and a set property call. The context is an object of type DPClientInvocationContext.

The DPClientInvocationContext hierarchy is shown below. Entries after the dash indicate the fields in the context.

DPClientInvocationContext

  • DPClientMethodCallContext - method name, arguments

  • DPClientGetPropertyContext - property name

  • DPClientSetPropertyContext - property name, value

Dependencies

  • dbus-python

  • into-dbus-python

Requirements

This library is not compatible with Python 2.

Project details


Download files

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

Source Distribution

dbus_python_client_gen-0.8.4.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dbus_python_client_gen-0.8.4-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file dbus_python_client_gen-0.8.4.tar.gz.

File metadata

  • Download URL: dbus_python_client_gen-0.8.4.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.9

File hashes

Hashes for dbus_python_client_gen-0.8.4.tar.gz
Algorithm Hash digest
SHA256 eaeeeb6c1f013b1f32f30d9da3379e9b9148970b71376c6924d762f07e988587
MD5 0a0adfee88c896c8e4ea1728899d76a1
BLAKE2b-256 12b6072184e88b385d74a1ae20e42a8c88ada4c1b2d8b8f2c740d2d035a102ee

See more details on using hashes here.

File details

Details for the file dbus_python_client_gen-0.8.4-py3-none-any.whl.

File metadata

File hashes

Hashes for dbus_python_client_gen-0.8.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3930b0f2ab1175376e53bfce0f5124f7227d831a818673eb60dcd0ba5a239bb9
MD5 b7d0031549a4bc959aa0148d456b1f47
BLAKE2b-256 36cef3cf273eee3c1c52640b87556f78db3546ce47ba8c124fe05503a837e10a

See more details on using hashes here.

Supported by

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