/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/bzr/smart/ping.py

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Ping plugin for brz."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
from ...commands import Command
22
20
from ...lazy_import import lazy_import
23
21
 
24
22
lazy_import(globals(), """
25
 
from breezy import errors
26
23
from breezy.bzr.smart.client import _SmartClient
27
24
from breezy.transport import get_transport
28
25
""")
29
26
 
 
27
from breezy import errors
 
28
 
30
29
 
31
30
class cmd_ping(Command):
32
31
    """Pings a Bazaar smart server.
46
45
        client = _SmartClient(medium)
47
46
        # Use call_expecting_body (even though we don't expect a body) so that
48
47
        # we can see the response headers (if any) via the handler object.
49
 
        response, handler = client.call_expecting_body('hello')
 
48
        response, handler = client.call_expecting_body(b'hello')
50
49
        handler.cancel_read_body()
51
50
        self.outf.write('Response: %r\n' % (response,))
52
51
        if getattr(handler, 'headers', None) is not None:
53
 
            self.outf.write('Headers: %r\n' % (handler.headers,))
 
52
            headers = {
 
53
                k.decode('utf-8'): v.decode('utf-8')
 
54
                for (k, v) in handler.headers.items()}
 
55
            self.outf.write('Headers: %r\n' % (headers,))