/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/remote.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:
24
24
 
25
25
__all__ = ['RemoteTransport', 'RemoteTCPTransport', 'RemoteSSHTransport']
26
26
 
27
 
from cStringIO import StringIO
28
 
 
29
 
from breezy import (
 
27
from .. import (
30
28
    config,
31
29
    debug,
32
30
    errors,
35
33
    transport,
36
34
    urlutils,
37
35
    )
38
 
from breezy.smart import client, medium
 
36
from ..sixish import (
 
37
    BytesIO,
 
38
    )
 
39
from ..smart import client, medium
39
40
 
40
41
 
41
42
class _SmartStat(object):
179
180
        """Call a method on the remote server."""
180
181
        try:
181
182
            return self._client.call(method, *args)
182
 
        except errors.ErrorFromSmartServer, err:
 
183
        except errors.ErrorFromSmartServer as err:
183
184
            # The first argument, if present, is always a path.
184
185
            if args:
185
186
                context = {'relpath': args[0]}
191
192
        """Call a method on the remote server with body bytes."""
192
193
        try:
193
194
            return self._client.call_with_body_bytes(method, args, body)
194
 
        except errors.ErrorFromSmartServer, err:
 
195
        except errors.ErrorFromSmartServer as err:
195
196
            # The first argument, if present, is always a path.
196
197
            if args:
197
198
                context = {'relpath': args[0]}
217
218
 
218
219
        :see: Transport.get_bytes()/get_file()
219
220
        """
220
 
        return StringIO(self.get_bytes(relpath))
 
221
        return BytesIO(self.get_bytes(relpath))
221
222
 
222
223
    def get_bytes(self, relpath):
223
224
        remote = self._remote_path(relpath)
224
225
        try:
225
226
            resp, response_handler = self._client.call_expecting_body('get', remote)
226
 
        except errors.ErrorFromSmartServer, err:
 
227
        except errors.ErrorFromSmartServer as err:
227
228
            self._translate_error(err, relpath)
228
229
        if resp != ('ok', ):
229
230
            response_handler.cancel_read_body()
360
361
                    ('readv', self._remote_path(relpath),),
361
362
                    [(c.start, c.length) for c in cur_request])
362
363
                resp, response_handler = result
363
 
            except errors.ErrorFromSmartServer, err:
 
364
            except errors.ErrorFromSmartServer as err:
364
365
                self._translate_error(err, relpath)
365
366
 
366
367
            if resp[0] != 'readv':
599
600
    """Return (transport, server) permutations for testing."""
600
601
    ### We may need a little more test framework support to construct an
601
602
    ### appropriate RemoteTransport in the future.
602
 
    from breezy.tests import test_server
 
603
    from ..tests import test_server
603
604
    return [(RemoteTCPTransport, test_server.SmartTCPServer_for_testing)]