~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/ftp_server.py

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

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
216
    def __init__(self):
250
250
        # Don't let it loop forever, or handle an infinite number of requests.
251
251
        # In this case it will run for 1000s, or 10000 requests
252
252
        self._async_thread = threading.Thread(
253
 
                target=FTPTestServer._asyncore_loop_ignore_EBADF,
 
253
                target=FTPServer._asyncore_loop_ignore_EBADF,
254
254
                kwargs={'timeout':0.1, 'count':10000})
255
255
        self._async_thread.setDaemon(True)
256
256
        self._async_thread.start()
279
279
            if e.args[0] != errno.EBADF:
280
280
                raise
281
281
 
282
 
    def add_user(self, user, password):
283
 
        """Add a user with write access."""
284
 
        authorizer = server = self._ftp_server.authorizer
285
 
        authorizer.secured_user = user
286
 
        authorizer.secured_password = password
 
282
 
 
283
 
287
284