~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lsprof.py

  • Committer: Ian Clatworthy
  • Date: 2007-09-10 06:23:31 UTC
  • mto: (2818.1.1 ianc-integration)
  • mto: This revision was merged to the branch mainline in revision 2819.
  • Revision ID: ian.clatworthy@internode.on.net-20070910062331-j985z2fu9amnylcq
incorporate feedback from lifeless

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
import threading
11
11
from _lsprof import Profiler, profiler_entry
12
12
 
 
13
 
 
14
import bzrlib.osutils
 
15
 
 
16
 
13
17
__all__ = ['profile', 'Stats']
14
18
 
15
19
_g_threadmap = {}
36
40
    # is taken straight from run_bzr_catch_errrors() in commands.py and ought
37
41
    # to be kept in sync with it.
38
42
    try:
39
 
        ret = f(*args, **kwds)
40
 
    except (KeyboardInterrupt, Exception), e:
41
 
        import bzrlib.trace
42
 
        bzrlib.trace.report_exception(sys.exc_info(), sys.stderr)
43
 
        ret = 3
 
43
        try:
 
44
            ret = f(*args, **kwds)
 
45
        except Exception:
 
46
            import bzrlib.trace
 
47
            bzrlib.trace.report_exception(sys.exc_info(), sys.stderr)
 
48
            ret = 3
44
49
    finally:
45
50
        p.disable()
46
51
        for pp in _g_threadmap.values():
126
131
            otherwise the format is given by the filename extension.
127
132
        """
128
133
        if format is None:
129
 
            basename = os.path.basename(filename)
 
134
            basename = bzrlib.osutils.basename(filename)
130
135
            if basename.startswith('callgrind.out'):
131
136
                format = "callgrind"
132
137
            else:
133
 
                ext = os.path.splitext(filename)[1]
 
138
                ext = bzrlib.osutils.splitext(filename)[1]
134
139
                if len(ext) > 1:
135
140
                    format = ext[1:]
136
141
        outfile = open(filename, 'wb')