1
# Copyright (C) 2005, 2006 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
146
152
if size <= 4 << 20:
148
154
old_fname = trace_fname + '.old'
149
from osutils import rename
150
rename(trace_fname, old_fname)
155
osutils.rename(trace_fname, old_fname)
310
315
def report_exception(exc_info, err_file):
316
"""Report an exception to err_file (typically stderr) and to .bzr.log.
318
This will show either a full traceback or a short message as appropriate.
320
:return: The appropriate exit code for this error.
311
322
exc_type, exc_object, exc_tb = exc_info
312
323
# Log the full traceback to ~/.bzr.log
313
324
log_exception_quietly()
314
325
if (isinstance(exc_object, IOError)
315
326
and getattr(exc_object, 'errno', None) == errno.EPIPE):
316
327
print >>err_file, "bzr: broken pipe"
328
return errors.EXIT_ERROR
317
329
elif isinstance(exc_object, KeyboardInterrupt):
318
330
print >>err_file, "bzr: interrupted"
331
return errors.EXIT_ERROR
319
332
elif not getattr(exc_object, 'internal_error', True):
320
333
report_user_error(exc_info, err_file)
334
return errors.EXIT_ERROR
321
335
elif isinstance(exc_object, (OSError, IOError)):
322
336
# Might be nice to catch all of these and show them as something more
323
337
# specific, but there are too many cases at the moment.
324
338
report_user_error(exc_info, err_file)
339
return errors.EXIT_ERROR
326
341
report_bug(exc_info, err_file)
342
return errors.EXIT_INTERNAL_ERROR
329
345
# TODO: Should these be specially encoding the output?
352
368
'.'.join(map(str, sys.version_info)),
354
370
print >>err_file, 'arguments: %r' % sys.argv
356
print >>err_file, "** please send this report to bazaar@lists.ubuntu.com"
372
'encoding: %r, fsenc: %r, lang: %r\n' % (
373
osutils.get_user_encoding(), sys.getfilesystemencoding(),
374
os.environ.get('LANG')))
375
err_file.write("plugins:\n")
376
for name, a_plugin in sorted(plugin.plugins().items()):
377
err_file.write(" %-20s %s [%s]\n" %
378
(name, a_plugin.path(), a_plugin.__version__))
381
"** Please send this report to bazaar@lists.ubuntu.com\n"
382
" with a description of what you were doing when the\n"