/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/tests/ftp_server.py

  • Committer: John Arbash Meinel
  • Date: 2009-02-23 15:29:35 UTC
  • mfrom: (3943.7.7 bzr.code_style_cleanup)
  • mto: This revision was merged to the branch mainline in revision 4033.
  • Revision ID: john@arbash-meinel.com-20090223152935-oel9m92mwcc6nb4h
Merge the removal of all trailing whitespace, and resolve conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007 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
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
"""
17
17
FTP test server.
18
18
 
33
33
from bzrlib import (
34
34
    tests,
35
35
    trace,
 
36
    transport,
36
37
    )
37
 
from bzrlib.tests import test_server
38
38
 
39
39
 
40
40
class test_filesystem(medusa.filesys.os_filesystem):
210
210
        trace.mutter('ftp_server %s: %s', type, message)
211
211
 
212
212
 
213
 
class FTPTestServer(test_server.TestServer):
 
213
class FTPServer(transport.Server):
214
214
    """Common code for FTP server facilities."""
215
215
 
216
 
    no_unicode_support = True
217
 
 
218
216
    def __init__(self):
219
217
        self._root = None
220
218
        self._ftp_server = None
235
233
        """This is used by medusa.ftp_server to log connections, etc."""
236
234
        self.logs.append(message)
237
235
 
238
 
    def start_server(self, vfs_server=None):
239
 
        if not (vfs_server is None or isinstance(vfs_server,
240
 
                                                 test_server.LocalURLServer)):
 
236
    def setUp(self, vfs_server=None):
 
237
        from bzrlib.transport.local import LocalURLServer
 
238
        if not (vfs_server is None or isinstance(vfs_server, LocalURLServer)):
241
239
            raise AssertionError(
242
240
                "FTPServer currently assumes local transport, got %s" % vfs_server)
243
241
        self._root = os.getcwdu()
252
250
        # Don't let it loop forever, or handle an infinite number of requests.
253
251
        # In this case it will run for 1000s, or 10000 requests
254
252
        self._async_thread = threading.Thread(
255
 
                target=FTPTestServer._asyncore_loop_ignore_EBADF,
 
253
                target=FTPServer._asyncore_loop_ignore_EBADF,
256
254
                kwargs={'timeout':0.1, 'count':10000})
257
255
        self._async_thread.setDaemon(True)
258
256
        self._async_thread.start()
259
257
 
260
 
    def stop_server(self):
 
258
    def tearDown(self):
 
259
        """See bzrlib.transport.Server.tearDown."""
261
260
        self._ftp_server.close()
262
261
        asyncore.close_all()
263
262
        self._async_thread.join()
280
279
            if e.args[0] != errno.EBADF:
281
280
                raise
282
281
 
283
 
    def add_user(self, user, password):
284
 
        """Add a user with write access."""
285
 
        authorizer = server = self._ftp_server.authorizer
286
 
        authorizer.secured_user = user
287
 
        authorizer.secured_password = password
 
282
 
 
283
 
288
284