/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/transport/log.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-22 00:56:52 UTC
  • mfrom: (6621.2.26 py3_pokes)
  • Revision ID: jelmer@jelmer.uk-20170522005652-yjahcr9hwmjkno7n
Merge Python3 porting work ('py3 pokes')

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Transport decorator that logs transport operations to .bzr.log."""
 
17
"""Transport decorator that logs transport operations to .brz.log."""
18
18
 
 
19
from __future__ import absolute_import
19
20
 
20
21
# see also the transportstats plugin, which gives you some summary information
21
22
# in a machine-readable dump
22
23
 
23
 
import StringIO
24
 
import cStringIO
25
24
import time
26
25
import types
27
26
 
28
 
from bzrlib.trace import mutter
29
 
from bzrlib.transport import decorator
 
27
from ..trace import mutter
 
28
from ..transport import decorator
30
29
 
31
30
 
32
31
class TransportLogDecorator(decorator.TransportDecorator):
33
 
    """Decorator for Transports that logs interesting operations to .bzr.log.
 
32
    """Decorator for Transports that logs interesting operations to .brz.log.
34
33
 
35
34
    In general we want to log things that usually take a network round trip
36
35
    and may be slow.
90
89
        before = time.time()
91
90
        try:
92
91
            result = getattr(self._decorated, methodname)(*args, **kwargs)
93
 
        except Exception, e:
 
92
        except Exception as e:
94
93
            mutter("  --> %s" % e)
95
94
            mutter("      %.03fs" % (time.time() - before))
96
95
            raise
108
107
            return_result = iter(result)
109
108
        else:
110
109
            return_result = result
111
 
        if isinstance(result, (cStringIO.OutputType, StringIO.StringIO)):
112
 
            val = repr(result.getvalue())
 
110
        # Is this an io object with a getvalue() method?
 
111
        getvalue = getattr(result, 'getvalue', None)
 
112
        if getvalue is not None:
 
113
            val = repr(getvalue())
113
114
            result_len = len(val)
114
115
            shown_result = "%s(%s) (%d bytes)" % (result.__class__.__name__,
115
116
                self._shorten(val), result_len)
150
151
 
151
152
def get_test_permutations():
152
153
    """Return the permutations to be used in testing."""
153
 
    from bzrlib.tests import test_server
 
154
    from ..tests import test_server
154
155
    return [(TransportLogDecorator, test_server.LogDecoratorServer)]