~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/server.py

  • Committer: John Arbash Meinel
  • Date: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
import errno
20
20
import os.path
21
 
import select
22
21
import socket
23
22
import sys
24
23
import threading
25
24
 
26
 
from bzrlib.hooks import HookPoint, Hooks
 
25
from bzrlib.hooks import Hooks
27
26
from bzrlib import (
28
27
    errors,
29
28
    trace,
30
 
    transport,
 
29
    transport as _mod_transport,
31
30
)
32
31
from bzrlib.lazy_import import lazy_import
33
32
lazy_import(globals(), """
34
33
from bzrlib.smart import medium
35
34
from bzrlib.transport import (
36
35
    chroot,
37
 
    get_transport,
38
36
    pathfilter,
39
37
    )
40
38
from bzrlib import (
105
103
        # The URL that a commit done on the same machine as the server will
106
104
        # have within the servers space. (e.g. file:///home/user/source)
107
105
        # The URL that will be given to other hooks in the same process -
108
 
        # the URL of the backing transport itself. (e.g. chroot+:///)
 
106
        # the URL of the backing transport itself. (e.g. filtered-36195:///)
109
107
        # We need all three because:
110
108
        #  * other machines see the first
111
109
        #  * local commits on this machine should be able to be mapped to
178
176
 
179
177
    def get_url(self):
180
178
        """Return the url of the server"""
181
 
        return "bzr://%s:%d/" % self._sockname
 
179
        return "bzr://%s:%s/" % (self._sockname[0], self._sockname[1])
182
180
 
183
181
    def serve_conn(self, conn, thread_name_suffix):
184
182
        # For WIN32, where the timeout value from the listening socket
241
239
        These are all empty initially, because by default nothing should get
242
240
        notified.
243
241
        """
244
 
        Hooks.__init__(self)
245
 
        self.create_hook(HookPoint('server_started',
 
242
        Hooks.__init__(self, "bzrlib.smart.server", "SmartTCPServer.hooks")
 
243
        self.add_hook('server_started',
246
244
            "Called by the bzr server when it starts serving a directory. "
247
245
            "server_started is called with (backing urls, public url), "
248
246
            "where backing_url is a list of URLs giving the "
249
247
            "server-specific directory locations, and public_url is the "
250
 
            "public URL for the directory being served.", (0, 16), None))
251
 
        self.create_hook(HookPoint('server_started_ex',
 
248
            "public URL for the directory being served.", (0, 16))
 
249
        self.add_hook('server_started_ex',
252
250
            "Called by the bzr server when it starts serving a directory. "
253
251
            "server_started is called with (backing_urls, server_obj).",
254
 
            (1, 17), None))
255
 
        self.create_hook(HookPoint('server_stopped',
 
252
            (1, 17))
 
253
        self.add_hook('server_stopped',
256
254
            "Called by the bzr server when it stops serving a directory. "
257
255
            "server_stopped is called with the same parameters as the "
258
 
            "server_started hook: (backing_urls, public_url).", (0, 16), None))
 
256
            "server_started hook: (backing_urls, public_url).", (0, 16))
259
257
 
260
258
SmartTCPServer.hooks = SmartServerHooks()
261
259
 
327
325
        chroot_server = chroot.ChrootServer(transport)
328
326
        chroot_server.start_server()
329
327
        self.cleanups.append(chroot_server.stop_server)
330
 
        transport = get_transport(chroot_server.get_url())
 
328
        transport = _mod_transport.get_transport(chroot_server.get_url())
331
329
        if self.base_path is not None:
332
330
            # Decorate the server's backing transport with a filter that can
333
331
            # expand homedirs.
334
332
            expand_userdirs = self._make_expand_userdirs_filter(transport)
335
333
            expand_userdirs.start_server()
336
334
            self.cleanups.append(expand_userdirs.stop_server)
337
 
            transport = get_transport(expand_userdirs.get_url())
 
335
            transport = _mod_transport.get_transport(expand_userdirs.get_url())
338
336
        self.transport = transport
339
337
 
340
338
    def _make_smart_server(self, host, port, inet):