~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/crash.py

  • Committer: Martin Pool
  • Date: 2010-02-02 18:44:57 UTC
  • mto: (4999.3.1 apport)
  • mto: This revision was merged to the branch mainline in revision 5002.
  • Revision ID: mbp@sourcefrog.net-20100202184457-wesqyxlzbmtz8fzg
Better check for APPORT_DISABLE; review tweaks from Robert

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
In principle apport can run on any platform though as of Feb 2010 there seem
34
34
to be some portability bugs.
 
35
 
 
36
To force this off in bzr turn set APPORT_DISBLE in the environment or 
 
37
-Dno_apport.
35
38
"""
36
39
 
37
40
# for interactive testing, try the 'bzr assert-fail' command 
58
61
 
59
62
 
60
63
def report_bug(exc_info, stderr):
61
 
    if ('no_apport' in debug.debug_flags) or (
62
 
        'APPORT_DISABLE' in os.environ):
 
64
    if ('no_apport' in debug.debug_flags) or \
 
65
        os.environ.get('APPORT_DISABLE', None):
63
66
        return report_bug_legacy(exc_info, stderr)
64
67
    try:
65
 
        report_bug_to_apport(exc_info, stderr)
66
 
        return
 
68
        if report_bug_to_apport(exc_info, stderr):
 
69
            # wrote a file; if None then report the old way
 
70
            return
67
71
    except ImportError, e:
68
72
        trace.mutter("couldn't find apport bug-reporting library: %s" % e)
69
73
        pass
102
106
 
103
107
def report_bug_to_apport(exc_info, stderr):
104
108
    """Report a bug to apport for optional automatic filing.
 
109
 
 
110
    :returns: The name of the crash file, or None if we didn't write one.
105
111
    """
106
112
    # this function is based on apport_package_hook.py, but omitting some of the
107
113
    # Ubuntu-specific policy about what to report and when
112
118
 
113
119
    crash_filename = _write_apport_report_to_file(exc_info)
114
120
 
115
 
    trace.print_exception(exc_info, stderr)
116
121
    if crash_filename is None:
117
122
        stderr.write("\n"
118
123
            "apport is set to ignore crashes in this version of bzr.\n"
119
124
            )
120
125
    else:
 
126
        trace.print_exception(exc_info, stderr)
121
127
        stderr.write("\n"
122
128
            "You can report this problem to Bazaar's developers by running\n"
123
129
            "    apport-bug %s\n"