/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/smart/client.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:
16
16
 
17
17
from __future__ import absolute_import
18
18
 
19
 
from breezy import lazy_import
 
19
from .. import lazy_import
20
20
lazy_import.lazy_import(globals(), """
21
21
from breezy.smart import request as _mod_request
22
22
""")
23
23
 
24
24
import breezy
25
 
from breezy.smart import message, protocol
26
 
from breezy import (
 
25
from . import message, protocol
 
26
from .. import (
27
27
    debug,
28
28
    errors,
29
29
    hooks,
73
73
 
74
74
    def call_with_body_bytes(self, method, args, body):
75
75
        """Call a method on the remote server with body bytes."""
76
 
        if type(method) is not str:
 
76
        if not isinstance(method, str):
77
77
            raise TypeError('method must be a byte string, not %r' % (method,))
78
78
        for arg in args:
79
 
            if type(arg) is not str:
 
79
            if not isinstance(arg, str):
80
80
                raise TypeError('args must be byte strings, not %r' % (args,))
81
 
        if type(body) is not str:
 
81
        if not isinstance(body, str):
82
82
            raise TypeError('body must be byte string, not %r' % (body,))
83
83
        response, response_handler = self._call_and_read_response(
84
84
            method, args, body=body, expect_response_body=False)
86
86
 
87
87
    def call_with_body_bytes_expecting_body(self, method, args, body):
88
88
        """Call a method on the remote server with body bytes."""
89
 
        if type(method) is not str:
 
89
        if not isinstance(method, str):
90
90
            raise TypeError('method must be a byte string, not %r' % (method,))
91
91
        for arg in args:
92
 
            if type(arg) is not str:
 
92
            if not isinstance(arg, str):
93
93
                raise TypeError('args must be byte strings, not %r' % (args,))
94
 
        if type(body) is not str:
 
94
        if not isinstance(body, str):
95
95
            raise TypeError('body must be byte string, not %r' % (body,))
96
96
        response, response_handler = self._call_and_read_response(
97
97
            method, args, body=body, expect_response_body=True)
190
190
        try:
191
191
            response_tuple = response_handler.read_response_tuple(
192
192
                expect_body=self.expect_response_body)
193
 
        except errors.ConnectionReset, e:
 
193
        except errors.ConnectionReset as e:
194
194
            self.client._medium.reset()
195
195
            if not self._is_safe_to_send_twice():
196
196
                raise
216
216
                self.client._medium._remember_remote_is_before((1, 6))
217
217
            try:
218
218
                response_tuple, response_handler = self._call(protocol_version)
219
 
            except errors.UnexpectedProtocolVersionMarker, err:
 
219
            except errors.UnexpectedProtocolVersionMarker as err:
220
220
                # TODO: We could recover from this without disconnecting if
221
221
                # we recognise the protocol version.
222
222
                trace.warning(
265
265
        encoder, response_handler = self._construct_protocol(protocol_version)
266
266
        try:
267
267
            self._send_no_retry(encoder)
268
 
        except errors.ConnectionReset, e:
 
268
        except errors.ConnectionReset as e:
269
269
            # If we fail during the _send_no_retry phase, then we can
270
270
            # be confident that the server did not get our request, because we
271
271
            # haven't started waiting for the reply yet. So try the request
344
344
        return '<%s %r>' % (self.__class__.__name__, attrs)
345
345
 
346
346
    def __eq__(self, other):
347
 
        if type(other) is not type(self):
 
347
        if not isinstance(other, type(self)):
348
348
            return NotImplemented
349
349
        return self.__dict__ == other.__dict__
350
350