~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/ftp.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-10-22 20:45:28 UTC
  • mfrom: (2921.1.4 dirstate.cache)
  • Revision ID: pqm@pqm.ubuntu.com-20071022204528-m4i3ievs46d19324
(robertc) Add a last-lookup cache to DirState reducing the cost of serial access to paths. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 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
"""Implementation of Transport over ftp.
17
17
 
18
18
Written by Daniel Silverstone <dsilvers@digital-scurf.org> with serious
25
25
"""
26
26
 
27
27
from cStringIO import StringIO
 
28
import asyncore
 
29
import errno
28
30
import ftplib
29
 
import getpass
30
31
import os
31
 
import random
32
 
import socket
 
32
import os.path
 
33
import urllib
 
34
import urlparse
 
35
import select
33
36
import stat
 
37
import threading
34
38
import time
 
39
import random
 
40
from warnings import warn
35
41
 
36
42
from bzrlib import (
37
 
    config,
38
43
    errors,
39
44
    osutils,
40
45
    urlutils,
42
47
from bzrlib.trace import mutter, warning
43
48
from bzrlib.transport import (
44
49
    AppendBasedFileStream,
45
 
    ConnectedTransport,
46
50
    _file_streams,
47
 
    register_urlparse_netloc_protocol,
48
51
    Server,
 
52
    ConnectedTransport,
49
53
    )
50
 
 
51
 
 
52
 
register_urlparse_netloc_protocol('aftp')
 
54
from bzrlib.transport.local import LocalURLServer
 
55
import bzrlib.ui
 
56
 
 
57
_have_medusa = False
53
58
 
54
59
 
55
60
class FtpPathError(errors.PathError):
57
62
 
58
63
 
59
64
class FtpStatResult(object):
60
 
 
61
 
    def __init__(self, f, abspath):
 
65
    def __init__(self, f, relpath):
62
66
        try:
63
 
            self.st_size = f.size(abspath)
 
67
            self.st_size = f.size(relpath)
64
68
            self.st_mode = stat.S_IFREG
65
69
        except ftplib.error_perm:
66
70
            pwd = f.pwd()
67
71
            try:
68
 
                f.cwd(abspath)
 
72
                f.cwd(relpath)
69
73
                self.st_mode = stat.S_IFDIR
70
74
            finally:
71
75
                f.cwd(pwd)
84
88
 
85
89
    def __init__(self, base, _from_transport=None):
86
90
        """Set the base path where files will be stored."""
87
 
        if not (base.startswith('ftp://') or base.startswith('aftp://')):
88
 
            raise ValueError(base)
 
91
        assert base.startswith('ftp://') or base.startswith('aftp://')
89
92
        super(FtpTransport, self).__init__(base,
90
93
                                           _from_transport=_from_transport)
91
94
        self._unqualified_scheme = 'ftp'
94
97
        else:
95
98
            self.is_active = False
96
99
 
97
 
        # Most modern FTP servers support the APPE command. If ours doesn't, we
98
 
        # (re)set this flag accordingly later.
99
 
        self._has_append = True
100
 
 
101
100
    def _get_FTP(self):
102
101
        """Return the ftplib.FTP instance for this object."""
103
102
        # Ensures that a connection is established
108
107
            self._set_connection(connection, credentials)
109
108
        return connection
110
109
 
111
 
    connection_class = ftplib.FTP
112
 
 
113
110
    def _create_connection(self, credentials=None):
114
111
        """Create a new connection with the provided credentials.
115
112
 
117
114
 
118
115
        :return: The created connection and its associated credentials.
119
116
 
120
 
        The input credentials are only the password as it may have been
121
 
        entered interactively by the user and may be different from the one
122
 
        provided in base url at transport creation time.  The returned
123
 
        credentials are username, password.
 
117
        The credentials are only the password as it may have been entered
 
118
        interactively by the user and may be different from the one provided
 
119
        in base url at transport creation time.
124
120
        """
125
121
        if credentials is None:
126
 
            user, password = self._user, self._password
 
122
            password = self._password
127
123
        else:
128
 
            user, password = credentials
 
124
            password = credentials
129
125
 
130
 
        auth = config.AuthenticationConfig()
131
 
        if user is None:
132
 
            user = auth.get_user('ftp', self._host, port=self._port,
133
 
                                 default=getpass.getuser())
134
126
        mutter("Constructing FTP instance against %r" %
135
 
               ((self._host, self._port, user, '********',
 
127
               ((self._host, self._port, self._user, '********',
136
128
                self.is_active),))
137
129
        try:
138
 
            connection = self.connection_class()
 
130
            connection = ftplib.FTP()
139
131
            connection.connect(host=self._host, port=self._port)
140
 
            self._login(connection, auth, user, password)
 
132
            if self._user and self._user != 'anonymous' and \
 
133
                    password is None: # '' is a valid password
 
134
                get_password = bzrlib.ui.ui_factory.get_password
 
135
                password = get_password(prompt='FTP %(user)s@%(host)s password',
 
136
                                        user=self._user, host=self._host)
 
137
            connection.login(user=self._user, passwd=password)
141
138
            connection.set_pasv(not self.is_active)
142
 
            # binary mode is the default
143
 
            connection.voidcmd('TYPE I')
144
 
        except socket.error, e:
145
 
            raise errors.SocketConnectionError(self._host, self._port,
146
 
                                               msg='Unable to connect to',
147
 
                                               orig_error= e)
148
139
        except ftplib.error_perm, e:
149
140
            raise errors.TransportError(msg="Error setting up connection:"
150
141
                                        " %s" % str(e), orig_error=e)
151
 
        return connection, (user, password)
152
 
 
153
 
    def _login(self, connection, auth, user, password):
154
 
        # '' is a valid password
155
 
        if user and user != 'anonymous' and password is None:
156
 
            password = auth.get_password('ftp', self._host,
157
 
                                         user, port=self._port)
158
 
        connection.login(user=user, passwd=password)
 
142
        return connection, password
159
143
 
160
144
    def _reconnect(self):
161
145
        """Create a new connection with the previously used credentials"""
183
167
            or 'no such dir' in s
184
168
            or 'could not create file' in s # vsftpd
185
169
            or 'file doesn\'t exist' in s
186
 
            or 'rnfr command failed.' in s # vsftpd RNFR reply if file not found
187
170
            or 'file/directory not found' in s # filezilla server
188
 
            # Microsoft FTP-Service RNFR reply if file not found
189
 
            or (s.startswith('550 ') and 'unable to rename to' in extra)
190
171
            ):
191
172
            raise errors.NoSuchFile(path, extra=extra)
192
173
        if ('file exists' in s):
198
179
 
199
180
        if unknown_exc:
200
181
            raise unknown_exc(path, extra=extra)
201
 
        # TODO: jam 20060516 Consider re-raising the error wrapped in
 
182
        # TODO: jam 20060516 Consider re-raising the error wrapped in 
202
183
        #       something like TransportError, but this loses the traceback
203
184
        #       Also, 'sftp' has a generic 'Failure' mode, which we use failure_exc
204
185
        #       to handle. Consider doing something like that here.
205
186
        #raise TransportError(msg='Error for path: %s' % (path,), orig_error=e)
206
187
        raise
207
188
 
 
189
    def _remote_path(self, relpath):
 
190
        # XXX: It seems that ftplib does not handle Unicode paths
 
191
        # at the same time, medusa won't handle utf8 paths So if
 
192
        # we .encode(utf8) here (see ConnectedTransport
 
193
        # implementation), then we get a Server failure.  while
 
194
        # if we use str(), we get a UnicodeError, and the test
 
195
        # suite just skips testing UnicodePaths.
 
196
        relative = str(urlutils.unescape(relpath))
 
197
        remote_path = self._combine_paths(self._path, relative)
 
198
        return remote_path
 
199
 
208
200
    def has(self, relpath):
209
201
        """Does the target location exist?"""
210
202
        # FIXME jam 20060516 We *do* ask about directories in the test suite
303
295
            try:
304
296
                f.storbinary('STOR '+tmp_abspath, fp)
305
297
                self._rename_and_overwrite(tmp_abspath, abspath, f)
306
 
                self._setmode(relpath, mode)
307
298
                if bytes is not None:
308
299
                    return len(bytes)
309
300
                else:
345
336
            mutter("FTP mkd: %s", abspath)
346
337
            f = self._get_FTP()
347
338
            f.mkd(abspath)
348
 
            self._setmode(relpath, mode)
349
339
        except ftplib.error_perm, e:
350
340
            self._translate_perm_error(e, abspath,
351
341
                unknown_exc=errors.FileExists)
379
369
        """Append the text in the file-like object into the final
380
370
        location.
381
371
        """
382
 
        text = f.read()
383
372
        abspath = self._remote_path(relpath)
384
373
        if self.has(relpath):
385
374
            ftp = self._get_FTP()
387
376
        else:
388
377
            result = 0
389
378
 
390
 
        if self._has_append:
391
 
            mutter("FTP appe to %s", abspath)
392
 
            self._try_append(relpath, text, mode)
393
 
        else:
394
 
            self._fallback_append(relpath, text, mode)
 
379
        mutter("FTP appe to %s", abspath)
 
380
        self._try_append(relpath, f.read(), mode)
395
381
 
396
382
        return result
397
383
 
398
384
    def _try_append(self, relpath, text, mode=None, retries=0):
399
385
        """Try repeatedly to append the given text to the file at relpath.
400
 
 
 
386
        
401
387
        This is a recursive function. On errors, it will be called until the
402
388
        number of retries is exceeded.
403
389
        """
405
391
            abspath = self._remote_path(relpath)
406
392
            mutter("FTP appe (try %d) to %s", retries, abspath)
407
393
            ftp = self._get_FTP()
 
394
            ftp.voidcmd("TYPE I")
408
395
            cmd = "APPE %s" % abspath
409
396
            conn = ftp.transfercmd(cmd)
410
397
            conn.sendall(text)
411
398
            conn.close()
412
 
            self._setmode(relpath, mode)
 
399
            if mode:
 
400
                self._setmode(relpath, mode)
413
401
            ftp.getresp()
414
402
        except ftplib.error_perm, e:
415
 
            # Check whether the command is not supported (reply code 502)
416
 
            if str(e).startswith('502 '):
417
 
                warning("FTP server does not support file appending natively. "
418
 
                        "Performance may be severely degraded! (%s)", e)
419
 
                self._has_append = False
420
 
                self._fallback_append(relpath, text, mode)
421
 
            else:
422
 
                self._translate_perm_error(e, abspath, extra='error appending',
423
 
                    unknown_exc=errors.NoSuchFile)
 
403
            self._translate_perm_error(e, abspath, extra='error appending',
 
404
                unknown_exc=errors.NoSuchFile)
424
405
        except ftplib.error_temp, e:
425
406
            if retries > _number_of_retries:
426
 
                raise errors.TransportError(
427
 
                    "FTP temporary error during APPEND %s. Aborting."
428
 
                    % abspath, orig_error=e)
 
407
                raise errors.TransportError("FTP temporary error during APPEND %s." \
 
408
                        "Aborting." % abspath, orig_error=e)
429
409
            else:
430
410
                warning("FTP temporary error: %s. Retrying.", str(e))
431
411
                self._reconnect()
432
412
                self._try_append(relpath, text, mode, retries+1)
433
413
 
434
 
    def _fallback_append(self, relpath, text, mode = None):
435
 
        remote = self.get(relpath)
436
 
        remote.seek(0, os.SEEK_END)
437
 
        remote.write(text)
438
 
        remote.seek(0)
439
 
        return self.put_file(relpath, remote, mode)
440
 
 
441
414
    def _setmode(self, relpath, mode):
442
415
        """Set permissions on a path.
443
416
 
444
417
        Only set permissions if the FTP server supports the 'SITE CHMOD'
445
418
        extension.
446
419
        """
447
 
        if mode:
448
 
            try:
449
 
                mutter("FTP site chmod: setting permissions to %s on %s",
450
 
                       oct(mode), self._remote_path(relpath))
451
 
                ftp = self._get_FTP()
452
 
                cmd = "SITE CHMOD %s %s" % (oct(mode),
453
 
                                            self._remote_path(relpath))
454
 
                ftp.sendcmd(cmd)
455
 
            except ftplib.error_perm, e:
456
 
                # Command probably not available on this server
457
 
                warning("FTP Could not set permissions to %s on %s. %s",
458
 
                        oct(mode), self._remote_path(relpath), str(e))
 
420
        try:
 
421
            mutter("FTP site chmod: setting permissions to %s on %s",
 
422
                str(mode), self._remote_path(relpath))
 
423
            ftp = self._get_FTP()
 
424
            cmd = "SITE CHMOD %s %s" % (self._remote_path(relpath), str(mode))
 
425
            ftp.sendcmd(cmd)
 
426
        except ftplib.error_perm, e:
 
427
            # Command probably not available on this server
 
428
            warning("FTP Could not set permissions to %s on %s. %s",
 
429
                    str(mode), self._remote_path(relpath), str(e))
459
430
 
460
431
    # TODO: jam 20060516 I believe ftp allows you to tell an ftp server
461
432
    #       to copy something to another machine. And you may be able
486
457
            self._rename_and_overwrite(abs_from, abs_to, f)
487
458
        except ftplib.error_perm, e:
488
459
            self._translate_perm_error(e, abs_from,
489
 
                extra='unable to rename to %r' % (rel_to,),
 
460
                extra='unable to rename to %r' % (rel_to,), 
490
461
                unknown_exc=errors.PathError)
491
462
 
492
463
    def _rename_and_overwrite(self, abs_from, abs_to, f):
527
498
        mutter("FTP nlst: %s", basepath)
528
499
        f = self._get_FTP()
529
500
        try:
530
 
            try:
531
 
                paths = f.nlst(basepath)
532
 
            except ftplib.error_perm, e:
533
 
                self._translate_perm_error(e, relpath,
534
 
                                           extra='error with list_dir')
535
 
            except ftplib.error_temp, e:
536
 
                # xs4all's ftp server raises a 450 temp error when listing an
537
 
                # empty directory. Check for that and just return an empty list
538
 
                # in that case. See bug #215522
539
 
                if str(e).lower().startswith('450 no files found'):
540
 
                    mutter('FTP Server returned "%s" for nlst.'
541
 
                           ' Assuming it means empty directory',
542
 
                           str(e))
543
 
                    return []
544
 
                raise
545
 
        finally:
546
 
            # Restore binary mode as nlst switch to ascii mode to retrieve file
547
 
            # list
548
 
            f.voidcmd('TYPE I')
549
 
 
 
501
            paths = f.nlst(basepath)
 
502
        except ftplib.error_perm, e:
 
503
            self._translate_perm_error(e, relpath, extra='error with list_dir')
550
504
        # If FTP.nlst returns paths prefixed by relpath, strip 'em
551
505
        if paths and paths[0].startswith(basepath):
552
506
            entries = [path[len(basepath)+1:] for path in paths]
603
557
        return self.lock_read(relpath)
604
558
 
605
559
 
 
560
class FtpServer(Server):
 
561
    """Common code for FTP server facilities."""
 
562
 
 
563
    def __init__(self):
 
564
        self._root = None
 
565
        self._ftp_server = None
 
566
        self._port = None
 
567
        self._async_thread = None
 
568
        # ftp server logs
 
569
        self.logs = []
 
570
 
 
571
    def get_url(self):
 
572
        """Calculate an ftp url to this server."""
 
573
        return 'ftp://foo:bar@localhost:%d/' % (self._port)
 
574
 
 
575
#    def get_bogus_url(self):
 
576
#        """Return a URL which cannot be connected to."""
 
577
#        return 'ftp://127.0.0.1:1'
 
578
 
 
579
    def log(self, message):
 
580
        """This is used by medusa.ftp_server to log connections, etc."""
 
581
        self.logs.append(message)
 
582
 
 
583
    def setUp(self, vfs_server=None):
 
584
        if not _have_medusa:
 
585
            raise RuntimeError('Must have medusa to run the FtpServer')
 
586
 
 
587
        assert vfs_server is None or isinstance(vfs_server, LocalURLServer), \
 
588
            "FtpServer currently assumes local transport, got %s" % vfs_server
 
589
 
 
590
        self._root = os.getcwdu()
 
591
        self._ftp_server = _ftp_server(
 
592
            authorizer=_test_authorizer(root=self._root),
 
593
            ip='localhost',
 
594
            port=0, # bind to a random port
 
595
            resolver=None,
 
596
            logger_object=self # Use FtpServer.log() for messages
 
597
            )
 
598
        self._port = self._ftp_server.getsockname()[1]
 
599
        # Don't let it loop forever, or handle an infinite number of requests.
 
600
        # In this case it will run for 1000s, or 10000 requests
 
601
        self._async_thread = threading.Thread(
 
602
                target=FtpServer._asyncore_loop_ignore_EBADF,
 
603
                kwargs={'timeout':0.1, 'count':10000})
 
604
        self._async_thread.setDaemon(True)
 
605
        self._async_thread.start()
 
606
 
 
607
    def tearDown(self):
 
608
        """See bzrlib.transport.Server.tearDown."""
 
609
        self._ftp_server.close()
 
610
        asyncore.close_all()
 
611
        self._async_thread.join()
 
612
 
 
613
    @staticmethod
 
614
    def _asyncore_loop_ignore_EBADF(*args, **kwargs):
 
615
        """Ignore EBADF during server shutdown.
 
616
 
 
617
        We close the socket to get the server to shutdown, but this causes
 
618
        select.select() to raise EBADF.
 
619
        """
 
620
        try:
 
621
            asyncore.loop(*args, **kwargs)
 
622
            # FIXME: If we reach that point, we should raise an exception
 
623
            # explaining that the 'count' parameter in setUp is too low or
 
624
            # testers may wonder why their test just sits there waiting for a
 
625
            # server that is already dead. Note that if the tester waits too
 
626
            # long under pdb the server will also die.
 
627
        except select.error, e:
 
628
            if e.args[0] != errno.EBADF:
 
629
                raise
 
630
 
 
631
 
 
632
_ftp_channel = None
 
633
_ftp_server = None
 
634
_test_authorizer = None
 
635
 
 
636
 
 
637
def _setup_medusa():
 
638
    global _have_medusa, _ftp_channel, _ftp_server, _test_authorizer
 
639
    try:
 
640
        import medusa
 
641
        import medusa.filesys
 
642
        import medusa.ftp_server
 
643
    except ImportError:
 
644
        return False
 
645
 
 
646
    _have_medusa = True
 
647
 
 
648
    class test_authorizer(object):
 
649
        """A custom Authorizer object for running the test suite.
 
650
 
 
651
        The reason we cannot use dummy_authorizer, is because it sets the
 
652
        channel to readonly, which we don't always want to do.
 
653
        """
 
654
 
 
655
        def __init__(self, root):
 
656
            self.root = root
 
657
            # If secured_user is set secured_password will be checked
 
658
            self.secured_user = None
 
659
            self.secured_password = None
 
660
 
 
661
        def authorize(self, channel, username, password):
 
662
            """Return (success, reply_string, filesystem)"""
 
663
            if not _have_medusa:
 
664
                return 0, 'No Medusa.', None
 
665
 
 
666
            channel.persona = -1, -1
 
667
            if username == 'anonymous':
 
668
                channel.read_only = 1
 
669
            else:
 
670
                channel.read_only = 0
 
671
 
 
672
            # Check secured_user if set
 
673
            if (self.secured_user is not None
 
674
                and username == self.secured_user
 
675
                and password != self.secured_password):
 
676
                return 0, 'Password invalid.', None
 
677
            else:
 
678
                return 1, 'OK.', medusa.filesys.os_filesystem(self.root)
 
679
 
 
680
 
 
681
    class ftp_channel(medusa.ftp_server.ftp_channel):
 
682
        """Customized ftp channel"""
 
683
 
 
684
        def log(self, message):
 
685
            """Redirect logging requests."""
 
686
            mutter('_ftp_channel: %s', message)
 
687
 
 
688
        def log_info(self, message, type='info'):
 
689
            """Redirect logging requests."""
 
690
            mutter('_ftp_channel %s: %s', type, message)
 
691
 
 
692
        def cmd_rnfr(self, line):
 
693
            """Prepare for renaming a file."""
 
694
            self._renaming = line[1]
 
695
            self.respond('350 Ready for RNTO')
 
696
            # TODO: jam 20060516 in testing, the ftp server seems to
 
697
            #       check that the file already exists, or it sends
 
698
            #       550 RNFR command failed
 
699
 
 
700
        def cmd_rnto(self, line):
 
701
            """Rename a file based on the target given.
 
702
 
 
703
            rnto must be called after calling rnfr.
 
704
            """
 
705
            if not self._renaming:
 
706
                self.respond('503 RNFR required first.')
 
707
            pfrom = self.filesystem.translate(self._renaming)
 
708
            self._renaming = None
 
709
            pto = self.filesystem.translate(line[1])
 
710
            if os.path.exists(pto):
 
711
                self.respond('550 RNTO failed: file exists')
 
712
                return
 
713
            try:
 
714
                os.rename(pfrom, pto)
 
715
            except (IOError, OSError), e:
 
716
                # TODO: jam 20060516 return custom responses based on
 
717
                #       why the command failed
 
718
                # (bialix 20070418) str(e) on Python 2.5 @ Windows
 
719
                # sometimes don't provide expected error message;
 
720
                # so we obtain such message via os.strerror()
 
721
                self.respond('550 RNTO failed: %s' % os.strerror(e.errno))
 
722
            except:
 
723
                self.respond('550 RNTO failed')
 
724
                # For a test server, we will go ahead and just die
 
725
                raise
 
726
            else:
 
727
                self.respond('250 Rename successful.')
 
728
 
 
729
        def cmd_size(self, line):
 
730
            """Return the size of a file
 
731
 
 
732
            This is overloaded to help the test suite determine if the 
 
733
            target is a directory.
 
734
            """
 
735
            filename = line[1]
 
736
            if not self.filesystem.isfile(filename):
 
737
                if self.filesystem.isdir(filename):
 
738
                    self.respond('550 "%s" is a directory' % (filename,))
 
739
                else:
 
740
                    self.respond('550 "%s" is not a file' % (filename,))
 
741
            else:
 
742
                self.respond('213 %d' 
 
743
                    % (self.filesystem.stat(filename)[stat.ST_SIZE]),)
 
744
 
 
745
        def cmd_mkd(self, line):
 
746
            """Create a directory.
 
747
 
 
748
            Overloaded because default implementation does not distinguish
 
749
            *why* it cannot make a directory.
 
750
            """
 
751
            if len (line) != 2:
 
752
                self.command_not_understood(''.join(line))
 
753
            else:
 
754
                path = line[1]
 
755
                try:
 
756
                    self.filesystem.mkdir (path)
 
757
                    self.respond ('257 MKD command successful.')
 
758
                except (IOError, OSError), e:
 
759
                    # (bialix 20070418) str(e) on Python 2.5 @ Windows
 
760
                    # sometimes don't provide expected error message;
 
761
                    # so we obtain such message via os.strerror()
 
762
                    self.respond ('550 error creating directory: %s' %
 
763
                                  os.strerror(e.errno))
 
764
                except:
 
765
                    self.respond ('550 error creating directory.')
 
766
 
 
767
 
 
768
    class ftp_server(medusa.ftp_server.ftp_server):
 
769
        """Customize the behavior of the Medusa ftp_server.
 
770
 
 
771
        There are a few warts on the ftp_server, based on how it expects
 
772
        to be used.
 
773
        """
 
774
        _renaming = None
 
775
        ftp_channel_class = ftp_channel
 
776
 
 
777
        def __init__(self, *args, **kwargs):
 
778
            mutter('Initializing _ftp_server: %r, %r', args, kwargs)
 
779
            medusa.ftp_server.ftp_server.__init__(self, *args, **kwargs)
 
780
 
 
781
        def log(self, message):
 
782
            """Redirect logging requests."""
 
783
            mutter('_ftp_server: %s', message)
 
784
 
 
785
        def log_info(self, message, type='info'):
 
786
            """Override the asyncore.log_info so we don't stipple the screen."""
 
787
            mutter('_ftp_server %s: %s', type, message)
 
788
 
 
789
    _test_authorizer = test_authorizer
 
790
    _ftp_channel = ftp_channel
 
791
    _ftp_server = ftp_server
 
792
 
 
793
    return True
 
794
 
 
795
 
606
796
def get_test_permutations():
607
797
    """Return the permutations to be used in testing."""
608
 
    from bzrlib.tests import ftp_server
609
 
    return [(FtpTransport, ftp_server.FTPTestServer)]
 
798
    if not _setup_medusa():
 
799
        warn("You must install medusa (http://www.amk.ca/python/code/medusa.html) for FTP tests")
 
800
        return []
 
801
    else:
 
802
        return [(FtpTransport, FtpServer)]