breezy-desktop/ui/lib/pydbus-0.6.0.dist-info/DESCRIPTION.rst

3.0 KiB

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> </head>

pydbus

https://travis-ci.org/LEW21/pydbus.svg?branch=master

Pythonic DBus library.

Changelog: https://github.com/LEW21/pydbus/releases

Requirements

  • Python 2.7+ - but works best on 3.4+ (help system is nicer there)
  • PyGI (not packaged on pypi, you need to install it from your distribution's repository - it's usually called python-gi, python-gobject or pygobject)
  • GLib 2.46+ and girepository 1.46+ (Ubuntu 16.04+) - for object publication support

Examples

Send a desktop notification

System Message: WARNING/2 (<stdin>, line 27)

Cannot analyze code. Pygments package not found.

.. code-block:: python

        from pydbus import SessionBus

        bus = SessionBus()
        notifications = bus.get('.Notifications')

        notifications.Notify('test', 0, 'dialog-information', "Hello World!", "pydbus works :)", [], {}, 5000)

List systemd units

System Message: WARNING/2 (<stdin>, line 38)

Cannot analyze code. Pygments package not found.

.. code-block:: python

        from pydbus import SystemBus

        bus = SystemBus()
        systemd = bus.get(".systemd1")

        for unit in systemd.ListUnits():
            print(unit)

Start or stop systemd unit

System Message: WARNING/2 (<stdin>, line 49)

Title underline too short.

Start or stop systemd unit
~~~~~~~~~~~~~~~~~~

System Message: WARNING/2 (<stdin>, line 50)

Cannot analyze code. Pygments package not found.

.. code-block:: python

        from pydbus import SystemBus

        bus = SystemBus()
        systemd = bus.get(".systemd1")

        job1 = systemd.StopUnit("ssh.service", "fail")
        job2 = systemd.StartUnit("ssh.service", "fail")

Watch for new systemd jobs

System Message: WARNING/2 (<stdin>, line 62)

Cannot analyze code. Pygments package not found.

.. code-block:: python

        from pydbus import SystemBus
        from gi.repository import GLib

        bus = SystemBus()
        systemd = bus.get(".systemd1")

        systemd.JobNew.connect(print)
        GLib.MainLoop().run()

        # or

        systemd.onJobNew = print
        GLib.MainLoop().run()

View object's API

System Message: WARNING/2 (<stdin>, line 80)

Cannot analyze code. Pygments package not found.

.. code-block:: python

        from pydbus import SessionBus

        bus = SessionBus()
        notifications = bus.get('.Notifications')

        help(notifications)

More examples & documentation

The Tutorial contains more examples and docs.

</html>