~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/crash.py

  • Committer: Martin Pool
  • Date: 2009-08-20 04:57:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4632.
  • Revision ID: mbp@sourcefrog.net-20090820045706-45jgxfpsb6jfvudi
Better handling of ImportError from apport

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
        try:
43
43
            report_bug_to_apport(exc_info, stderr)
44
44
            return
 
45
        except ImportError, e:
 
46
            trace.mutter("couldn't find apport bug-reporting library: %s" % e)
 
47
            pass
45
48
        except Exception, e:
46
49
            # this should only happen if apport is installed but it didn't
47
50
            # work, eg because of an io error writing the crash file
77
80
 
78
81
def report_bug_to_apport(exc_info, stderr):
79
82
    """Report a bug to apport for optional automatic filing.
80
 
    
81
 
    :returns: True if the bug was filed or otherwise handled; 
82
 
        False to use a fallback method.
83
83
    """
84
84
    # this is based on apport_package_hook.py, but omitting some of the
85
85
    # Ubuntu-specific policy about what to report and when
86
 
    try:
87
 
        from apport.report import Report
88
 
    except ImportError, e:
89
 
        trace.mutter("couldn't find apport bug-reporting library: %s" % e)
90
 
        return False
 
86
 
 
87
    # if this fails its caught at a higher level; we don't want to open the
 
88
    # crash file unless apport can be loaded.
 
89
    import apport
91
90
 
92
91
    crash_file = _open_crash_file()
93
92
    try:
108
107
        "    private information.\n"
109
108
        % (exc_info[0].__module__, exc_info[0].__name__, exc_info[1],
110
109
           crash_file.name))
111
 
    return True
112
110
 
113
111
 
114
112
def _write_apport_report_to_file(exc_info, crash_file):