~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Joe Julian
  • Date: 2010-01-10 02:25:31 UTC
  • mto: (4634.119.7 2.0)
  • mto: This revision was merged to the branch mainline in revision 4959.
  • Revision ID: joe@julianfamily.org-20100110022531-wqk61rsagz8xsiga
Added MANIFEST.in to allow bdist_rpm to have all the required include files and tools. bdist_rpm will still fail to build correctly on some distributions due to a disttools bug http://bugs.python.org/issue644744

Show diffs side-by-side

added added

removed removed

Lines of Context:
237
237
            bzr_log_file.write("bug reports to https://bugs.launchpad.net/bzr/+filebug\n\n")
238
238
        return bzr_log_file
239
239
    except IOError, e:
240
 
        warning("failed to open trace file: %s" % (e))
 
240
        # If we are failing to open the log, then most likely logging has not
 
241
        # been set up yet. So we just write to stderr rather than using
 
242
        # 'warning()'. If we using warning(), users get the unhelpful 'no
 
243
        # handlers registered for "bzr"' when something goes wrong on the
 
244
        # server. (bug #503886)
 
245
        sys.stderr.write("failed to open trace file: %s\n" % (e,))
241
246
    # TODO: What should happen if we fail to open the trace file?  Maybe the
242
247
    # objects should be pointed at /dev/null or the equivalent?  Currently
243
248
    # returns None which will cause failures later.
432
437
    elif isinstance(exc_object, KeyboardInterrupt):
433
438
        err_file.write("bzr: interrupted\n")
434
439
        return errors.EXIT_ERROR
 
440
    elif isinstance(exc_object, MemoryError):
 
441
        err_file.write("bzr: out of memory\n")
 
442
        return errors.EXIT_ERROR
435
443
    elif isinstance(exc_object, ImportError) \
436
444
        and str(exc_object).startswith("No module named "):
437
445
        report_user_error(exc_info, err_file,
478
486
 
479
487
def report_bug(exc_info, err_file):
480
488
    """Report an exception that probably indicates a bug in bzr"""
481
 
    print_exception(exc_info, err_file)
482
 
    err_file.write('\n')
483
 
    err_file.write('bzr %s on python %s (%s)\n' % \
484
 
                       (bzrlib.__version__,
485
 
                        bzrlib._format_version_tuple(sys.version_info),
486
 
                        sys.platform))
487
 
    err_file.write('arguments: %r\n' % sys.argv)
488
 
    err_file.write(
489
 
        'encoding: %r, fsenc: %r, lang: %r\n' % (
490
 
            osutils.get_user_encoding(), sys.getfilesystemencoding(),
491
 
            os.environ.get('LANG')))
492
 
    err_file.write("plugins:\n")
493
 
    for name, a_plugin in sorted(plugin.plugins().items()):
494
 
        err_file.write("  %-20s %s [%s]\n" %
495
 
            (name, a_plugin.path(), a_plugin.__version__))
496
 
    err_file.write(
497
 
"""\
498
 
*** Bazaar has encountered an internal error.
499
 
    Please report a bug at https://bugs.launchpad.net/bzr/+filebug
500
 
    including this traceback, and a description of what you
501
 
    were doing when the error occurred.
502
 
""")
 
489
    from bzrlib.crash import report_bug
 
490
    report_bug(exc_info, err_file)