~gnome3-team/gnome-screensaver/ubuntu

52 by Marc Deslauriers
- Added apport hook
1
#!/usr/bin/python
2
3
'''Apport package hook for gnome-screensaver
4
5
(c) 2010 Canonical Ltd.
6
Contributors:
7
Marc Deslauriers <marc.deslauriers@canonical.com>
66 by Chris Coulson
* debian/source_gnome-screensaver.py:
8
Chris Coulson <chris.coulson@canonical.com>
52 by Marc Deslauriers
- Added apport hook
9
10
This program is free software; you can redistribute it and/or modify it
11
under the terms of the GNU General Public License as published by the
12
Free Software Foundation; either version 2 of the License, or (at your
13
option) any later version.  See http://www.gnu.org/copyleft/gpl.html for
14
the full text of the license.
15
'''
16
17
from apport.hookutils import *
66 by Chris Coulson
* debian/source_gnome-screensaver.py:
18
import dbus
52 by Marc Deslauriers
- Added apport hook
19
20
def add_info(report):
21
22
    attach_file_if_exists(report, '/etc/X11/xorg.conf', 'XorgConf')
23
    attach_file_if_exists(report, '/var/log/Xorg.0.log', 'XorgLog')
24
    attach_file_if_exists(report, '/var/log/Xorg.0.log.old', 'XorgLogOld')
25
26
    report['WindowManager'] = command_output(['gconftool-2','--get','/desktop/gnome/session/required_components/windowmanager'])
27
28
    # We want the whole thing, not just the changes
29
    report['GconfGnomeScreensaver'] = command_output(['gconftool-2', '-R', '/apps/gnome-screensaver'])
65 by Marc Deslauriers
* debian/source_gnome-screensaver.py: also add g-p-m gconf keys to help
30
    report['GconfGnomePowerManager'] = command_output(['gconftool-2', '-R', '/apps/gnome-power-manager'])
52 by Marc Deslauriers
- Added apport hook
31
    report['GconfGnomeSession'] = command_output(['gconftool-2', '-R', '/desktop/gnome/session'])
32
    report['GconfGnomeLockdown'] = command_output(['gconftool-2', '-R', '/desktop/gnome/lockdown'])
33
66 by Chris Coulson
* debian/source_gnome-screensaver.py:
34
    try:
35
        bus = dbus.SessionBus()
36
        session_manager = bus.get_object('org.gnome.SessionManager', '/org/gnome/SessionManager')
37
        session_manager_iface = dbus.Interface(session_manager, dbus_interface='org.gnome.SessionManager')
38
        inhibitors = session_manager_iface.GetInhibitors()
39
        inhibitors_str = ''
40
        master_flag = 0
41
        j = 1
42
        for i in inhibitors:
43
            obj = bus.get_object('org.gnome.SessionManager', i)
44
            iface = dbus.Interface(obj, dbus_interface='org.gnome.SessionManager.Inhibitor')
45
            app_id = iface.GetAppId()
46
            flags = iface.GetFlags()
47
            reason = iface.GetReason()
48
	    if j > 1:
49
		    inhibitors_str += '\n'
50
            inhibitors_str += str(j) + ': AppId = ' + app_id + ', Flags = ' + str(flags) + ', Reason = ' + reason
51
            j = j + 1
52
            master_flag |= flags
53
54
        report['GnomeSessionInhibitors'] = 'None' if inhibitors_str == '' else inhibitors_str
55
        report['GnomeSessionIdleInhibited'] = 'Yes' if master_flag & 8 else 'No'
56
    except:
57
        report['GnomeSessionInhibitors'] = 'Failed to acquire'
58
        report['GnomeSessionIdleInhibited'] = 'Unknown'
59
52 by Marc Deslauriers
- Added apport hook
60
if __name__ == '__main__':
61
    report = {}
62
    add_info(report)
63
    for key in report:
64
        print '[%s]\n%s' % (key, report[key])