~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/trace.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-04-18 04:55:00 UTC
  • mfrom: (5784.2.1 754188-apport-test)
  • Revision ID: pqm@pqm.ubuntu.com-20110418045500-ce6lkgyiq7f47q43
(mbp) Rewrite test_report_bug_legacy away from using doctest (see bug
 764188) (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
#
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
59
59
import os
60
60
import sys
61
61
import time
62
 
import tempfile
63
62
 
64
63
from bzrlib.lazy_import import lazy_import
65
64
lazy_import(globals(), """
66
65
from cStringIO import StringIO
67
66
import errno
68
67
import locale
 
68
import tempfile
69
69
import traceback
70
70
""")
71
71
 
81
81
    debug,
82
82
    errors,
83
83
    osutils,
84
 
    plugin,
85
 
    symbol_versioning,
86
84
    ui,
87
85
    )
88
86
""")
123
121
    # FIXME: clearing the ui and then going through the abstract logging
124
122
    # framework is whack; we should probably have a logging Handler that
125
123
    # deals with terminal output if needed.
126
 
    import bzrlib.ui
127
 
    bzrlib.ui.ui_factory.clear_term()
 
124
    ui.ui_factory.clear_term()
128
125
    _bzr_logger.info(*args, **kwargs)
129
126
 
130
127
 
131
128
def warning(*args, **kwargs):
132
 
    import bzrlib.ui
133
 
    bzrlib.ui.ui_factory.clear_term()
 
129
    ui.ui_factory.clear_term()
134
130
    _bzr_logger.warning(*args, **kwargs)
135
131
 
136
132
 
490
486
        elif fd is not None:
491
487
            os.close(fd)
492
488
 
 
489
 
 
490
def _qualified_exception_name(eclass, unqualified_bzrlib_errors=False):
 
491
    """Give name of error class including module for non-builtin exceptions
 
492
 
 
493
    If `unqualified_bzrlib_errors` is True, errors specific to bzrlib will
 
494
    also omit the module prefix.
 
495
    """
 
496
    class_name = eclass.__name__
 
497
    module_name = eclass.__module__
 
498
    if module_name in ("exceptions", "__main__") or (
 
499
            unqualified_bzrlib_errors and module_name == "bzrlib.errors"):
 
500
        return class_name
 
501
    return "%s.%s" % (module_name, class_name)
 
502
 
 
503
 
493
504
def report_exception(exc_info, err_file):
494
505
    """Report an exception to err_file (typically stderr) and to .bzr.log.
495
506