~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/ftp/__init__.py

  • Committer: Patch Queue Manager
  • Date: 2016-04-21 04:10:52 UTC
  • mfrom: (6616.1.1 fix-en-user-guide)
  • Revision ID: pqm@pqm.ubuntu.com-20160421041052-clcye7ns1qcl2n7w
(richard-wilbur) Ensure build of English use guide always uses English text
 even when user's locale specifies a different language. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
active, in which case aftp:// will be your friend.
26
26
"""
27
27
 
 
28
from __future__ import absolute_import
 
29
 
28
30
from cStringIO import StringIO
29
31
import ftplib
30
32
import getpass
96
98
        super(FtpTransport, self).__init__(base,
97
99
                                           _from_transport=_from_transport)
98
100
        self._unqualified_scheme = 'ftp'
99
 
        if self._scheme == 'aftp':
 
101
        if self._parsed_url.scheme == 'aftp':
100
102
            self.is_active = True
101
103
        else:
102
104
            self.is_active = False
203
205
            # Microsoft FTP-Service RNFR reply if file not found
204
206
            or (s.startswith('550 ') and 'unable to rename to' in extra)
205
207
            # if containing directory doesn't exist, suggested by
206
 
            # <https://bugs.edge.launchpad.net/bzr/+bug/224373>
 
208
            # <https://bugs.launchpad.net/bzr/+bug/224373>
207
209
            or (s.startswith('550 ') and "can't find folder" in s)
208
210
            ):
209
211
            raise errors.NoSuchFile(path, extra=extra)
246
248
            mutter("FTP has not: %s: %s", abspath, e)
247
249
            return False
248
250
 
249
 
    def get(self, relpath, decode=DEPRECATED_PARAMETER, retries=0):
 
251
    def get(self, relpath, retries=0):
250
252
        """Get the file at the given relative path.
251
253
 
252
254
        :param relpath: The relative path to the file
256
258
        We're meant to return a file-like object which bzr will
257
259
        then read from. For now we do this via the magic of StringIO
258
260
        """
259
 
        if deprecated_passed(decode):
260
 
            warn(deprecated_in((2,3,0)) %
261
 
                 '"decode" parameter to FtpTransport.get()',
262
 
                 DeprecationWarning, stacklevel=2)
263
261
        try:
264
262
            mutter("FTP get: %s", self._remote_path(relpath))
265
263
            f = self._get_FTP()
277
275
            else:
278
276
                warning("FTP temporary error: %s. Retrying.", str(e))
279
277
                self._reconnect()
280
 
                return self.get(relpath, decode, retries+1)
 
278
                return self.get(relpath, retries+1)
281
279
        except EOFError, e:
282
280
            if retries > _number_of_retries:
283
281
                raise errors.TransportError("FTP control connection closed during GET %s."
287
285
                warning("FTP control connection closed. Trying to reopen.")
288
286
                time.sleep(_sleep_between_retries)
289
287
                self._reconnect()
290
 
                return self.get(relpath, decode, retries+1)
 
288
                return self.get(relpath, retries+1)
291
289
 
292
290
    def put_file(self, relpath, fp, mode=None, retries=0):
293
291
        """Copy the file-like or string object into the location.