~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

  • Committer: Neil Santos
  • Date: 2010-02-25 03:23:48 UTC
  • mto: (5080.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5081.
  • Revision ID: neil_santos@users.sourceforge.net-20100225032348-pi4bes9ehqjg394c
Added default link() and symlink() methods to Transport.
Added implementation of link() and symlink() methods to LocalTransport.
Added implementation of symlink() method to SFTPTransport.
Added corresponding tests (symlink() fails for SFTPTransport for some reason; possibly a Paramiko bug?).
Committing in preparation for push and eventual merge proposal to mainline bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
else:
83
83
    from paramiko.sftp import (SFTP_FLAG_WRITE, SFTP_FLAG_CREATE,
84
84
                               SFTP_FLAG_EXCL, SFTP_FLAG_TRUNC,
85
 
                               CMD_HANDLE, CMD_OPEN)
 
85
                               SFTP_OK, CMD_HANDLE, CMD_OPEN)
86
86
    from paramiko.sftp_attr import SFTPAttributes
87
87
    from paramiko.sftp_file import SFTPFile
88
88
 
810
810
        """Return the stat information for a file."""
811
811
        path = self._remote_path(relpath)
812
812
        try:
813
 
            return self._get_sftp().stat(path)
 
813
            return self._get_sftp().lstat(path)
814
814
        except (IOError, paramiko.SSHException), e:
815
815
            self._translate_io_exception(e, path, ': unable to stat')
816
816
 
 
817
    def symlink(self, source, link_name):
 
818
        """See Transport.symlink."""
 
819
        try:
 
820
            conn = self._get_sftp()
 
821
            retval = conn.symlink(source, link_name)
 
822
            return (SFTP_OK == retval)
 
823
        except (IOError, paramiko.SSHException), e:
 
824
            self._translate_io_exception(e, link_name,
 
825
                                         ': unable to create symlink to %r' % (source))
 
826
 
817
827
    def lock_read(self, relpath):
818
828
        """
819
829
        Lock the given file for shared (read) access.