After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 472812 - Python Inhibit() example is out of date
Python Inhibit() example is out of date
Status: RESOLVED FIXED
Product: gnome-power-manager
Classification: Deprecated
Component: general
SVN TRUNK
Other All
: Normal minor
: ---
Assigned To: GNOME Power Manager Maintainer(s)
GNOME Power Manager Maintainer(s)
: 588124 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-09-02 13:05 UTC by Sitsofe Wheeler
Modified: 2014-03-27 14:01 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20



Description Sitsofe Wheeler 2007-09-02 13:05:56 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:
Comment 1 Ulrich Dangel 2009-01-03 16:40:45 UTC
#!/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)
Comment 2 Scott Howard 2009-07-20 21:14:52 UTC
*** Bug 588124 has been marked as a duplicate of this bug. ***
Comment 3 Scott Howard 2009-07-20 21:20:23 UTC
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.
Comment 4 Sitsofe Wheeler 2009-07-21 09:15:26 UTC
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...
Comment 5 Richard Hughes 2009-07-21 10:28:13 UTC
I've removed this file, and ported the inhibit applet to use gnome session, not gnome-power-manager.
Comment 6 Sitsofe Wheeler 2014-03-27 14:01:27 UTC
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...