~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/ftp.py

  • Committer: Martin Pool
  • Date: 2008-06-11 02:36:40 UTC
  • mfrom: (3490 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3492.
  • Revision ID: mbp@sourcefrog.net-20080611023640-db0lqd75yueksdw7
Merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
 
90
90
    def __init__(self, base, _from_transport=None):
91
91
        """Set the base path where files will be stored."""
92
 
        assert base.startswith('ftp://') or base.startswith('aftp://')
 
92
        if not (base.startswith('ftp://') or base.startswith('aftp://')):
 
93
            raise ValueError(base)
93
94
        super(FtpTransport, self).__init__(base,
94
95
                                           _from_transport=_from_transport)
95
96
        self._unqualified_scheme = 'ftp'
515
516
            paths = f.nlst(basepath)
516
517
        except ftplib.error_perm, e:
517
518
            self._translate_perm_error(e, relpath, extra='error with list_dir')
 
519
        except ftplib.error_temp, e:
 
520
            # xs4all's ftp server raises a 450 temp error when listing an empty
 
521
            # directory. Check for that and just return an empty list in that
 
522
            # case. See bug #215522
 
523
            if str(e).lower().startswith('450 no files found'):
 
524
                mutter('FTP Server returned "%s" for nlst.'
 
525
                       ' Assuming it means empty directory',
 
526
                       str(e))
 
527
                return []
 
528
            raise
518
529
        # If FTP.nlst returns paths prefixed by relpath, strip 'em
519
530
        if paths and paths[0].startswith(basepath):
520
531
            entries = [path[len(basepath)+1:] for path in paths]