~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-02-11 04:02:41 UTC
  • mfrom: (5017.2.2 tariff)
  • Revision ID: pqm@pqm.ubuntu.com-20100211040241-w6n021dz0uus341n
(mbp) add import-tariff tests

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
 
                               SFTP_OK, CMD_HANDLE, CMD_OPEN)
 
85
                               CMD_HANDLE, CMD_OPEN)
86
86
    from paramiko.sftp_attr import SFTPAttributes
87
87
    from paramiko.sftp_file import SFTPFile
88
88
 
389
389
                                         self._host, self._port)
390
390
        return connection, (user, password)
391
391
 
392
 
    def disconnect(self):
393
 
        connection = self._get_connection()
394
 
        if connection is not None:
395
 
            connection.close()
396
 
 
397
392
    def _get_sftp(self):
398
393
        """Ensures that a connection is established"""
399
394
        connection = self._get_connection()
720
715
            if (e.args[0].startswith('Directory not empty: ')
721
716
                or getattr(e, 'errno', None) == errno.ENOTEMPTY):
722
717
                raise errors.DirectoryNotEmpty(path, str(e))
723
 
            if e.args == ('Operation unsupported',):
724
 
                raise errors.TransportNotPossible()
725
718
            mutter('Raising exception with args %s', e.args)
726
719
        if getattr(e, 'errno', None) is not None:
727
720
            mutter('Raising exception with errno %s', e.errno)
817
810
        """Return the stat information for a file."""
818
811
        path = self._remote_path(relpath)
819
812
        try:
820
 
            return self._get_sftp().lstat(path)
 
813
            return self._get_sftp().stat(path)
821
814
        except (IOError, paramiko.SSHException), e:
822
815
            self._translate_io_exception(e, path, ': unable to stat')
823
816
 
824
 
    def readlink(self, relpath):
825
 
        """See Transport.readlink."""
826
 
        path = self._remote_path(relpath)
827
 
        try:
828
 
            return self._get_sftp().readlink(path)
829
 
        except (IOError, paramiko.SSHException), e:
830
 
            self._translate_io_exception(e, path, ': unable to readlink')
831
 
 
832
 
    def symlink(self, source, link_name):
833
 
        """See Transport.symlink."""
834
 
        try:
835
 
            conn = self._get_sftp()
836
 
            sftp_retval = conn.symlink(source, link_name)
837
 
            if SFTP_OK != sftp_retval:
838
 
                raise TransportError(
839
 
                    '%r: unable to create symlink to %r' % (link_name, source),
840
 
                    sftp_retval
841
 
                )
842
 
        except (IOError, paramiko.SSHException), e:
843
 
            self._translate_io_exception(e, link_name,
844
 
                                         ': unable to create symlink to %r' % (source))
845
 
 
846
817
    def lock_read(self, relpath):
847
818
        """
848
819
        Lock the given file for shared (read) access.