299
297
def report_bug(exc_info, err_file):
300
298
"""Report an exception that probably indicates a bug in bzr"""
301
# local import because its only needed here, and this is not a loop.
303
# local import because the other functions do it too.
305
# local import due to circular dependency
309
# detect apport presence.
311
import problem_report
313
# not present, dont use it.
316
# policy disabled, or not present, use the old ui.
317
return _old_report_bug(exc_info, err_file)
319
exc_type, exc_object, exc_tb = exc_info
321
"bzr: ERROR: %s.%s: %s\n" % (
322
exc_type.__module__, exc_type.__name__, exc_object)
324
report = problem_report.ProblemReport()
325
report_file, report_filename = tempfile.mkstemp(
326
suffix='.txt', prefix='bzr-crash-', dir='/tmp')
327
python_report_file = os.fdopen(report_file, 'w')
329
report['CommandLine'] = ' '.join(sys.argv)
330
# assume we are packaged as bzr.
331
apport_utils.report_add_package_info(report, 'bzr')
332
report['BzrPlugins'] = ' '.join(bzrlib.plugin.all_plugins())
334
traceback.print_exception(exc_type, exc_object, exc_tb, file=tb_file)
335
report['Traceback'] = tb_file.getvalue()
336
apport_utils.report_add_os_info(report)
337
report.write(python_report_file)
338
# give the user a pretty output.
341
'This is an unexpected error within bzr and we would appreciate a bug report.\n'
343
'bzr has written a crash report file that will assist our debugging of this\n'
346
'This is a plain text file, whose contents you can check if you have privacy\n'
347
'concerns. We gather the package data about bzr, your command line, plugins\n'
348
'And the backtrace from within bzr. If you had a password in the URL you\n'
349
'provided to bzr, you should edit that file to remove the password.\n'
351
'** To file a bug for this please visit our bugtracker at the URL \n'
352
'"https://launchpad.net/products/bzr/+filebug" and report a bug describing\n'
353
'what you were attempting and attach the bzr-crash file mentioned above.\n'
354
'Alternatively you can email bazaar-ng@lists.canonical.com with the same\n'
355
'description and attach the bzr-crash file to the email.\n' %
359
python_report_file.close()
360
return report, report_filename
362
def _old_report_bug(exc_info, err_file):
363
"""Write a synopsis of an exception that is probably a bug to err_file."""
365
300
exc_type, exc_object, exc_tb = exc_info
366
301
print >>err_file, "bzr: ERROR: %s.%s: %s" % (