Python DBUS bindings
Go to file
Linus Lewandowski 6be62734e6 Merge pull request #44 from hkwi/dtd
make direction attribute conforming to introspect.dtd
2017-02-05 16:15:18 +01:00
doc Update paths in the tutorial. 2016-12-18 16:10:55 +01:00
examples Move examples out of the package. 2016-12-18 16:10:42 +01:00
pydbus make direction attribute conforming to introspect.dtd 2017-02-01 18:00:33 +09:00
tests Move tests out of the package. 2016-12-18 15:55:35 +01:00
.gitignore Drop signal-spammer. 2016-12-18 16:17:03 +01:00
.travis.yml Test pydbus on GLib 2.40 (Ubuntu 14.04) too. 2016-09-26 00:21:26 +02:00
LICENSE Relicense the code to LGPLv2.1+. 2014-10-24 21:27:05 +02:00
MANIFEST.in Add LICENSE to the sdist. Fixes #39. 2016-12-18 16:33:45 +01:00
Makefile Release 0.6.0. 2016-12-18 17:27:02 +01:00
README.rst Fix typo in section title formatting in README.rst 2016-12-29 16:15:25 +01:00
setup.cfg Release 0.5. We're mostly feature complete! 2016-04-09 01:18:02 +02:00
setup.py Release 0.6.0. 2016-12-18 17:27:02 +01:00

README.rst

pydbus
======
.. image:: https://travis-ci.org/LEW21/pydbus.svg?branch=master
    :target: https://travis-ci.org/LEW21/pydbus
.. image:: https://badge.fury.io/py/pydbus.svg
    :target: https://badge.fury.io/py/pydbus

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

.. _PyGI: https://wiki.gnome.org/Projects/PyGObject
.. _GLib: https://developer.gnome.org/glib/
.. _girepository: https://wiki.gnome.org/Projects/GObjectIntrospection

Examples
--------

Send a desktop notification
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. 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
~~~~~~~~~~~~~~~~~~
.. 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
~~~~~~~~~~~~~~~~~~~~~~~~~~
.. 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
~~~~~~~~~~~~~~~~~~~~~~~~~~
.. 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
~~~~~~~~~~~~~~~~~
.. 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.

.. _Tutorial: https://github.com/LEW21/pydbus/blob/master/doc/tutorial.rst

Copyright Information
---------------------

Copyright (C) 2014, 2015, 2016 Linus Lewandowski <linus@lew21.net>

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