/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 bzrlib/smart/client.py

  • Committer: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

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 ... import lazy_import
 
19
from bzrlib import lazy_import
20
20
lazy_import.lazy_import(globals(), """
21
 
from breezy.bzr.smart import request as _mod_request
 
21
from bzrlib.smart import request as _mod_request
22
22
""")
23
23
 
24
 
import breezy
25
 
from . import message, protocol
26
 
from ... import (
 
24
import bzrlib
 
25
from bzrlib.smart import message, protocol
 
26
from bzrlib import (
27
27
    debug,
28
28
    errors,
29
29
    hooks,
40
40
        """
41
41
        self._medium = medium
42
42
        if headers is None:
43
 
            self._headers = {'Software version': breezy.__version__}
 
43
            self._headers = {'Software version': bzrlib.__version__}
44
44
        else:
45
45
            self._headers = dict(headers)
46
46
 
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 not isinstance(method, str):
 
76
        if type(method) is not str:
77
77
            raise TypeError('method must be a byte string, not %r' % (method,))
78
78
        for arg in args:
79
 
            if not isinstance(arg, str):
 
79
            if type(arg) is not str:
80
80
                raise TypeError('args must be byte strings, not %r' % (args,))
81
 
        if not isinstance(body, str):
 
81
        if type(body) is not 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 not isinstance(method, str):
 
89
        if type(method) is not str:
90
90
            raise TypeError('method must be a byte string, not %r' % (method,))
91
91
        for arg in args:
92
 
            if not isinstance(arg, str):
 
92
            if type(arg) is not str:
93
93
                raise TypeError('args must be byte strings, not %r' % (args,))
94
 
        if not isinstance(body, str):
 
94
        if type(body) is not 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 as e:
 
193
        except errors.ConnectionReset, 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 as err:
 
219
            except errors.UnexpectedProtocolVersionMarker, 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 as e:
 
268
        except errors.ConnectionReset, 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
318
318
class SmartClientHooks(hooks.Hooks):
319
319
 
320
320
    def __init__(self):
321
 
        hooks.Hooks.__init__(self, "breezy.bzr.smart.client", "_SmartClient.hooks")
 
321
        hooks.Hooks.__init__(self, "bzrlib.smart.client", "_SmartClient.hooks")
322
322
        self.add_hook('call',
323
323
            "Called when the smart client is submitting a request to the "
324
 
            "smart server. Called with a breezy.bzr.smart.client.CallHookParams "
 
324
            "smart server. Called with a bzrlib.smart.client.CallHookParams "
325
325
            "object. Streaming request bodies, and responses, are not "
326
326
            "accessible.", None)
327
327
 
339
339
        self.medium = medium
340
340
 
341
341
    def __repr__(self):
342
 
        attrs = dict((k, v) for k, v in self.__dict__.items()
 
342
        attrs = dict((k, v) for (k, v) in self.__dict__.iteritems()
343
343
                     if v is not None)
344
344
        return '<%s %r>' % (self.__class__.__name__, attrs)
345
345
 
346
346
    def __eq__(self, other):
347
 
        if not isinstance(other, type(self)):
 
347
        if type(other) is not type(self):
348
348
            return NotImplemented
349
349
        return self.__dict__ == other.__dict__
350
350