~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/ftp.py

  • Committer: John Arbash Meinel
  • Date: 2006-05-16 17:32:30 UTC
  • mto: This revision was merged to the branch mainline in revision 1724.
  • Revision ID: john@arbash-meinel.com-20060516173230-0919a3a599c202d5
Removing stipple from ftp tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
    def __init__(self, base, _provided_instance=None):
92
92
        """Set the base path where files will be stored."""
93
93
        assert base.startswith('ftp://') or base.startswith('aftp://')
 
94
        if not base.endswith('/'):
 
95
            mutter('FtpTransport adding / to %s', base)
 
96
            base += '/'
94
97
        super(FtpTransport, self).__init__(base)
95
98
        self.is_active = base.startswith('aftp://')
96
99
        if self.is_active:
138
141
    def _abspath(self, relpath):
139
142
        assert isinstance(relpath, basestring)
140
143
        relpath = urllib.unquote(relpath)
141
 
        if isinstance(relpath, basestring):
142
 
            relpath_parts = relpath.split('/')
143
 
        else:
144
 
            # TODO: Don't call this with an array - no magic interfaces
145
 
            relpath_parts = relpath[:]
 
144
        relpath_parts = relpath.split('/')
146
145
        if len(relpath_parts) > 1:
147
146
            if relpath_parts[0] == '':
148
147
                raise ValueError("path %r within branch %r seems to be absolute"
439
438
        return 1, 'OK.', medusa.filesys.os_filesystem(self.root)
440
439
 
441
440
 
 
441
if _have_medusa:
 
442
    class _ftp_server(medusa.ftp_server.ftp_server):
 
443
        """Customize the behavior of the Medusa ftp_server.
 
444
 
 
445
        There are a few warts on the ftp_server, based on how it expects
 
446
        to be used.
 
447
        """
 
448
 
 
449
        def log_info(self, message, type='info'):
 
450
            """Override the asyncore.log_info so we don't stipple the screen."""
 
451
            return
 
452
 
 
453
 
442
454
class FtpServer(Server):
443
455
    """Common code for SFTP server facilities."""
444
456
 
464
476
            raise RuntimeError('Must have medusa to run the FtpServer')
465
477
 
466
478
        self._root = os.getcwdu()
467
 
        self._ftp_server = medusa.ftp_server.ftp_server(
 
479
        self._ftp_server = _ftp_server(
468
480
            authorizer=_test_authorizer(root=self._root),
469
481
            ip='localhost',
470
482
            port=0, # bind to a random port