Merge lp:~mvo/apport/apport-checkreports-addition into lp:~apport-hackers/apport/trunk

Proposed by Michael Vogt
Status: Merged
Merged at revision: 1896
Proposed branch: lp:~mvo/apport/apport-checkreports-addition
Merge into: lp:~apport-hackers/apport/trunk
Diff against target: 83 lines (+21/-17)
3 files modified
apport/fileutils.py (+11/-0)
apport_python_hook.py (+2/-13)
data/apport-checkreports (+8/-4)
To merge this branch: bzr merge lp:~mvo/apport/apport-checkreports-addition
Reviewer Review Type Date Requested Status
Martin Pitt (community) Approve
Review via email: mp+63819@code.launchpad.net

Description of the change

This branch adds a new exit state for apport-checkreports (that is the helper that update-notifier is using). If apport is globally disabled but there are reports it now exits with status 2 and prints a message. This will make update-notifier not call the apport GUI is apport is disabled but there are reports comming in. It also moves the enabled() test into apport.fileutils

In addition to that I would like to add a new script apport-is-enabled that just returns 0/1. That I will then call in apt/aptdaemon to check that reports are actually enabled. Alternatively we could add a additional apport-checkreports --is-apport-enabled call if the additional binary is not wanted.

To post a comment you must log in.
1897. By Michael Vogt

apport_python_hook.py: remove the no longer needed CONFIG

Revision history for this message
Martin Pitt (pitti) wrote :

There is already apport.packaging.enabled(), so no need to redefine it again in fileutils.

The new exit status is fine for me, I'll merge that.

A new script apport-is-enabled also sounds ok to me, but I'd write it in dash, not python; calling a full python interpreter from dpkg/apt not only sounds very expensive to just check a single file, but also is prone to failures if the very thing we are reporting are failed packages.

review: Approve
Revision history for this message
Martin Pitt (pitti) wrote :

Also, apport_python_hook directly checks the file as importing any other apport module is too brittle. Please see bug 528355 for details.

Revision history for this message
Martin Pitt (pitti) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'apport/fileutils.py'
2--- apport/fileutils.py 2011-02-03 13:52:02 +0000
3+++ apport/fileutils.py 2011-06-08 08:48:00 +0000
4@@ -25,6 +25,17 @@
5
6 _config_file = '~/.config/apport/settings'
7
8+def apport_enabled():
9+ '''Return whether Apport should generate crash reports.'''
10+ CONFIG = '/etc/default/apport'
11+ import re
12+ try:
13+ conf = open(CONFIG).read()
14+ return re.search('^\s*enabled\s*=\s*0\s*$', conf, re.M) is None
15+ except IOError:
16+ # if the file does not exist, assume it's enabled
17+ return True
18+
19 def find_package_desktopfile(package):
20 '''Return a package's .desktop file.
21
22
23=== modified file 'apport_python_hook.py'
24--- apport_python_hook.py 2011-02-28 10:58:32 +0000
25+++ apport_python_hook.py 2011-06-08 08:48:00 +0000
26@@ -13,18 +13,7 @@
27 import os
28 import sys
29
30-CONFIG = '/etc/default/apport'
31-
32-def enabled():
33- '''Return whether Apport should generate crash reports.'''
34-
35- import re
36- try:
37- conf = open(CONFIG).read()
38- return re.search('^\s*enabled\s*=\s*0\s*$', conf, re.M) is None
39- except IOError:
40- # if the file does not exist, assume it's enabled
41- return True
42+from apport.fileutils import apport_enabled
43
44 def apport_excepthook(exc_type, exc_obj, exc_tb):
45 '''Catch an uncaught exception and make a traceback.'''
46@@ -45,7 +34,7 @@
47 return
48
49 # do not do anything if apport was disabled
50- if not enabled():
51+ if not apport_enabled():
52 return
53
54 try:
55
56=== modified file 'data/apport-checkreports'
57--- data/apport-checkreports 2009-09-08 10:30:40 +0000
58+++ data/apport-checkreports 2011-06-08 08:48:00 +0000
59@@ -14,7 +14,7 @@
60
61 import sys, os.path, optparse
62
63-from apport.fileutils import get_new_reports, get_new_system_reports
64+from apport.fileutils import get_new_reports, get_new_system_reports, apport_enabled
65
66 # parse command line options
67 optparser = optparse.OptionParser('%prog [options]')
68@@ -29,8 +29,12 @@
69 reports = get_new_reports()
70
71 if len(reports) > 0:
72- for r in reports:
73- print r.split('.')[0].split('_')[-1]
74- sys.exit(0)
75+ if apport_enabled():
76+ for r in reports:
77+ print r.split('.')[0].split('_')[-1]
78+ sys.exit(0)
79+ else:
80+ print "new reports but apport disabled"
81+ sys.exit(2)
82 else:
83 sys.exit(1)

Subscribers

People subscribed via source and target branches