~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: 2008-06-05 04:05:05 UTC
  • mfrom: (3473.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080605040505-i9kqxg2fps2qjdi0
Add the 'alias' command (Tim Penhey)

Show diffs side-by-side

added added

removed removed

Lines of Context:
116
116
 
117
117
        :return: The created connection and its associated credentials.
118
118
 
119
 
        The input credentials are only the password as it may have been
120
 
        entered interactively by the user and may be different from the one
121
 
        provided in base url at transport creation time.  The returned
122
 
        credentials are username, password.
 
119
        The credentials are only the password as it may have been entered
 
120
        interactively by the user and may be different from the one provided
 
121
        in base url at transport creation time.
123
122
        """
124
123
        if credentials is None:
125
124
            user, password = self._user, self._password
311
310
            try:
312
311
                f.storbinary('STOR '+tmp_abspath, fp)
313
312
                self._rename_and_overwrite(tmp_abspath, abspath, f)
314
 
                self._setmode(relpath, mode)
315
313
                if bytes is not None:
316
314
                    return len(bytes)
317
315
                else:
353
351
            mutter("FTP mkd: %s", abspath)
354
352
            f = self._get_FTP()
355
353
            f.mkd(abspath)
356
 
            self._setmode(relpath, mode)
357
354
        except ftplib.error_perm, e:
358
355
            self._translate_perm_error(e, abspath,
359
356
                unknown_exc=errors.FileExists)
414
411
            conn = ftp.transfercmd(cmd)
415
412
            conn.sendall(text)
416
413
            conn.close()
417
 
            self._setmode(relpath, mode)
 
414
            if mode:
 
415
                self._setmode(relpath, mode)
418
416
            ftp.getresp()
419
417
        except ftplib.error_perm, e:
420
418
            self._translate_perm_error(e, abspath, extra='error appending',
434
432
        Only set permissions if the FTP server supports the 'SITE CHMOD'
435
433
        extension.
436
434
        """
437
 
        if mode:
438
 
            try:
439
 
                mutter("FTP site chmod: setting permissions to %s on %s",
440
 
                    str(mode), self._remote_path(relpath))
441
 
                ftp = self._get_FTP()
442
 
                cmd = "SITE CHMOD %s %s" % (oct(mode),
443
 
                                            self._remote_path(relpath))
444
 
                ftp.sendcmd(cmd)
445
 
            except ftplib.error_perm, e:
446
 
                # Command probably not available on this server
447
 
                warning("FTP Could not set permissions to %s on %s. %s",
448
 
                        str(mode), self._remote_path(relpath), str(e))
 
435
        try:
 
436
            mutter("FTP site chmod: setting permissions to %s on %s",
 
437
                str(mode), self._remote_path(relpath))
 
438
            ftp = self._get_FTP()
 
439
            cmd = "SITE CHMOD %s %s" % (self._remote_path(relpath), str(mode))
 
440
            ftp.sendcmd(cmd)
 
441
        except ftplib.error_perm, e:
 
442
            # Command probably not available on this server
 
443
            warning("FTP Could not set permissions to %s on %s. %s",
 
444
                    str(mode), self._remote_path(relpath), str(e))
449
445
 
450
446
    # TODO: jam 20060516 I believe ftp allows you to tell an ftp server
451
447
    #       to copy something to another machine. And you may be able