/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:
21
21
# see also the transportstats plugin, which gives you some summary information
22
22
# in a machine-readable dump
23
23
 
24
 
import StringIO
25
 
import cStringIO
26
24
import time
27
25
import types
28
26
 
29
 
from breezy.trace import mutter
30
 
from breezy.transport import decorator
 
27
from ..trace import mutter
 
28
from ..transport import decorator
31
29
 
32
30
 
33
31
class TransportLogDecorator(decorator.TransportDecorator):
91
89
        before = time.time()
92
90
        try:
93
91
            result = getattr(self._decorated, methodname)(*args, **kwargs)
94
 
        except Exception, e:
 
92
        except Exception as e:
95
93
            mutter("  --> %s" % e)
96
94
            mutter("      %.03fs" % (time.time() - before))
97
95
            raise
109
107
            return_result = iter(result)
110
108
        else:
111
109
            return_result = result
112
 
        if isinstance(result, (cStringIO.OutputType, StringIO.StringIO)):
113
 
            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())
114
114
            result_len = len(val)
115
115
            shown_result = "%s(%s) (%d bytes)" % (result.__class__.__name__,
116
116
                self._shorten(val), result_len)
151
151
 
152
152
def get_test_permutations():
153
153
    """Return the permutations to be used in testing."""
154
 
    from breezy.tests import test_server
 
154
    from ..tests import test_server
155
155
    return [(TransportLogDecorator, test_server.LogDecoratorServer)]