~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/ftp_server/pyftpdlib_based.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009 Canonical Ltd
 
1
# Copyright (C) 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
50
50
 
51
51
    def listdir(self, path):
52
52
        """List the content of a directory."""
53
 
        # FIXME: need tests with unicode paths
54
53
        return [osutils.safe_utf8(s) for s in os.listdir(path)]
55
54
 
56
55
    def fs2ftp(self, fspath):
57
 
        p = ftpserver.AbstractedFS.fs2ftp(self, fspath)
58
 
        # FIXME: need tests with unicode paths
 
56
        p = ftpserver.AbstractedFS.fs2ftp(self, osutils.safe_unicode(fspath))
59
57
        return osutils.safe_utf8(p)
60
58
 
 
59
    def ftp2fs(self, ftppath):
 
60
        p = osutils.safe_unicode(ftppath)
 
61
        return ftpserver.AbstractedFS.ftp2fs(self, p)
61
62
 
62
63
class BzrConformingFTPHandler(ftpserver.FTPHandler):
63
64
 
156
157
        """This is used by ftp_server to log connections, etc."""
157
158
        self.logs.append(message)
158
159
 
159
 
    def setUp(self, vfs_server=None):
 
160
    def start_server(self, vfs_server=None):
160
161
        from bzrlib.transport.local import LocalURLServer
161
162
        if not (vfs_server is None or isinstance(vfs_server, LocalURLServer)):
162
163
            raise AssertionError(
186
187
        self._ftpd_starting.acquire()
187
188
        self._ftpd_starting.release()
188
189
 
189
 
    def tearDown(self):
190
 
        """See bzrlib.transport.Server.tearDown."""
 
190
    def stop_server(self):
 
191
        """See bzrlib.transport.Server.stop_server."""
191
192
        # Tell the server to stop, but also close the server socket for tests
192
193
        # that start the server but never initiate a connection. Closing the
193
194
        # socket should be done first though, to avoid further connections.
196
197
        self._ftpd_thread.join()
197
198
 
198
199
    def _run_server(self):
199
 
        """Run the server until tearDown is called, shut it down properly then.
 
200
        """Run the server until stop_server is called, shut it down properly then.
200
201
        """
201
202
        self._ftpd_running = True
202
203
        self._ftpd_starting.release()