~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/ftp_server.py

  • Committer: Mark Hammond
  • Date: 2009-01-12 01:55:34 UTC
  • mto: (3995.8.2 prepare-1.12)
  • mto: This revision was merged to the branch mainline in revision 4007.
  • Revision ID: mhammond@skippinet.com.au-20090112015534-yfxg50p7mpds9j4v
Include all .html files from the tortoise doc directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008, 2009 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
 
126
126
    def cmd_size(self, line):
127
127
        """Return the size of a file
128
128
 
129
 
        This is overloaded to help the test suite determine if the
 
129
        This is overloaded to help the test suite determine if the 
130
130
        target is a directory.
131
131
        """
132
132
        filename = line[1]
136
136
            else:
137
137
                self.respond('550 "%s" is not a file' % (filename,))
138
138
        else:
139
 
            self.respond('213 %d'
 
139
            self.respond('213 %d' 
140
140
                % (self.filesystem.stat(filename)[stat.ST_SIZE]),)
141
141
 
142
142
    def cmd_mkd(self, line):
210
210
        trace.mutter('ftp_server %s: %s', type, message)
211
211
 
212
212
 
213
 
class FTPTestServer(transport.Server):
 
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):
 
236
    def setUp(self, vfs_server=None):
239
237
        from bzrlib.transport.local import LocalURLServer
240
238
        if not (vfs_server is None or isinstance(vfs_server, LocalURLServer)):
241
239
            raise AssertionError(
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