GNOME Bugzilla – Bug 472812
Python Inhibit() example is out of date
Last modified: 2014-03-27 14:01:27 UTC
The python inhibit example on http://svn.gnome.org/viewcvs/gnome-power-manager/trunk/docs/dbus-test-inhibit.py?revision=2121&view=markup is out of date and generates the following error when attempting to run it: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "Inhibit" with signature "ss" on interface "org.freedesktop.PowerManagement.Inhibit" doesn't exist Additionally the example on http://live.gnome.org/GnomePowerManager/FAQ#head-1cf52551bcec3107d7bae8c332fd292ec2261760 seems to even more out of date and refers to a dbus path that has been superseded. Other information:
#!/usr/bin/env python import dbus bus = dbus.SessionBus() devobj = bus.get_object('org.freedesktop.PowerManagement', '/org/freedesktop/PowerManagement/Inhibit') power = dbus.Interface(devobj, "org.freedesktop.PowerManagement.Inhibit") cookie = power.Inhibit('application name', 'reason') power.UnInhibit(cookie)
*** Bug 588124 has been marked as a duplicate of this bug. ***
Marked the above bug a duplicate of this one. From Richard Hughes' blog: http://blogs.gnome.org/hughsie/2009/01/28/inhibits-and-the-new-world-order/ inhibit is now a method of: org.gnome.SessionManager The API and documentation is now in gnome session manager, and the GPM inhibit is no longer in GPM 2.27+. Therefore, the above examples won't work anymore. However, the documentation on the GPM project website still references the GPM inhibit method.
The internal docs are also out of date: here's an updated link to the repo that I posted above (now that GNOME uses git rather than subversion): http://git.gnome.org./cgit/gnome-power-manager/tree/docs/dbus-test-inhibit.py I guess there's a bit of cleaning up to do...
I've removed this file, and ported the inhibit applet to use gnome session, not gnome-power-manager.
The original gnome live docs have gone, the git docs have gone so there all the python gnome inhibit examples have gone. Poking about the net shows there's some easy to read out of date documentation on https://people.gnome.org/~mccann/gnome-session/docs/gnome-session.html#org.gnome.SessionManager.Inhibit and difficult to read modern documentation on https://git.gnome.org/browse/gnome-settings-daemon/tree/gnome-settings-daemon/org.gnome.SessionManager.xml . A small python example that seems to work for me (GNOME 3.10) is as follows: import dbus bus = dbus.SessionBus() proxy = bus.get_object('org.gnome.SessionManager','/org/gnome/SessionManager') proxy.Inhibit("Application Name", dbus.UInt32(0), "Reason for inhibiting", dbus.UInt32(8)) Let's close this as I don't see anyone rushing to add a new python example...