/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2011-07-06 08:58:15 UTC
  • mfrom: (5609.48.2 2.3)
  • mto: (6012.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6013.
  • Revision ID: v.ladeuil+lp@free.fr-20110706085815-6leauod52jq2u43d
MergingĀ inĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
    osutils,
41
41
    urlutils,
42
42
    )
 
43
from bzrlib.symbol_versioning import (
 
44
    DEPRECATED_PARAMETER,
 
45
    deprecated_in,
 
46
    deprecated_passed,
 
47
    warn,
 
48
    )
43
49
from bzrlib.trace import mutter, warning
44
50
from bzrlib.transport import (
45
51
    AppendBasedFileStream,
164
170
        connection, credentials = self._create_connection(credentials)
165
171
        self._set_connection(connection, credentials)
166
172
 
 
173
    def disconnect(self):
 
174
        connection = self._get_connection()
 
175
        if connection is not None:
 
176
            connection.close()
 
177
 
167
178
    def _translate_ftp_error(self, err, path, extra=None,
168
179
                              unknown_exc=FtpPathError):
169
180
        """Try to translate an ftplib exception to a bzrlib exception.
191
202
            or 'file/directory not found' in s # filezilla server
192
203
            # Microsoft FTP-Service RNFR reply if file not found
193
204
            or (s.startswith('550 ') and 'unable to rename to' in extra)
 
205
            # if containing directory doesn't exist, suggested by
 
206
            # <https://bugs.launchpad.net/bzr/+bug/224373>
 
207
            or (s.startswith('550 ') and "can't find folder" in s)
194
208
            ):
195
209
            raise errors.NoSuchFile(path, extra=extra)
196
210
        elif ('file exists' in s):
232
246
            mutter("FTP has not: %s: %s", abspath, e)
233
247
            return False
234
248
 
235
 
    def get(self, relpath, decode=False, retries=0):
 
249
    def get(self, relpath, decode=DEPRECATED_PARAMETER, retries=0):
236
250
        """Get the file at the given relative path.
237
251
 
238
252
        :param relpath: The relative path to the file
242
256
        We're meant to return a file-like object which bzr will
243
257
        then read from. For now we do this via the magic of StringIO
244
258
        """
245
 
        # TODO: decode should be deprecated
 
259
        if deprecated_passed(decode):
 
260
            warn(deprecated_in((2,3,0)) %
 
261
                 '"decode" parameter to FtpTransport.get()',
 
262
                 DeprecationWarning, stacklevel=2)
246
263
        try:
247
264
            mutter("FTP get: %s", self._remote_path(relpath))
248
265
            f = self._get_FTP()
314
331
                    return len(bytes)
315
332
                else:
316
333
                    return fp.counted_bytes
317
 
            except (ftplib.error_temp,EOFError), e:
318
 
                warning("Failure during ftp PUT. Deleting temporary file.")
 
334
            except (ftplib.error_temp, EOFError), e:
 
335
                warning("Failure during ftp PUT of %s: %s. Deleting temporary file."
 
336
                    % (tmp_abspath, e, ))
319
337
                try:
320
338
                    f.delete(tmp_abspath)
321
339
                except:
328
346
                                       unknown_exc=errors.NoSuchFile)
329
347
        except ftplib.error_temp, e:
330
348
            if retries > _number_of_retries:
331
 
                raise errors.TransportError("FTP temporary error during PUT %s. Aborting."
332
 
                                     % self.abspath(relpath), orig_error=e)
 
349
                raise errors.TransportError(
 
350
                    "FTP temporary error during PUT %s: %s. Aborting."
 
351
                    % (self.abspath(relpath), e), orig_error=e)
333
352
            else:
334
353
                warning("FTP temporary error: %s. Retrying.", str(e))
335
354
                self._reconnect()