~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/sftp.py

Move all features to bzrlib.tests.features in 2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
        except FileExists:
115
115
            raise LockError('File %r already locked' % (self.path,))
116
116
 
117
 
    def __del__(self):
118
 
        """Should this warn, or actually try to cleanup?"""
119
 
        if self.lock_file:
120
 
            warning("SFTPLock %r not explicitly unlocked" % (self.path,))
121
 
            self.unlock()
122
 
 
123
117
    def unlock(self):
124
118
        if not self.lock_file:
125
119
            return
281
275
                    buffered = buffered[buffered_offset:]
282
276
                    buffered_data = [buffered]
283
277
                    buffered_len = len(buffered)
 
278
        # now that the data stream is done, close the handle
 
279
        fp.close()
284
280
        if buffered_len:
285
281
            buffered = ''.join(buffered_data)
286
282
            del buffered_data[:]
389
385
                                         self._host, self._port)
390
386
        return connection, (user, password)
391
387
 
 
388
    def disconnect(self):
 
389
        connection = self._get_connection()
 
390
        if connection is not None:
 
391
            connection.close()
 
392
 
392
393
    def _get_sftp(self):
393
394
        """Ensures that a connection is established"""
394
395
        connection = self._get_connection()
416
417
        :param relpath: The relative path to the file
417
418
        """
418
419
        try:
419
 
            # FIXME: by returning the file directly, we don't pass this
420
 
            # through to report_activity.  We could try wrapping the object
421
 
            # before it's returned.  For readv and get_bytes it's handled in
422
 
            # the higher-level function.
423
 
            # -- mbp 20090126
424
420
            path = self._remote_path(relpath)
425
421
            f = self._get_sftp().file(path, mode='rb')
426
422
            if self._do_prefetch and (getattr(f, 'prefetch', None) is not None):
715
711
            if (e.args[0].startswith('Directory not empty: ')
716
712
                or getattr(e, 'errno', None) == errno.ENOTEMPTY):
717
713
                raise errors.DirectoryNotEmpty(path, str(e))
 
714
            if e.args == ('Operation unsupported',):
 
715
                raise errors.TransportNotPossible()
718
716
            mutter('Raising exception with args %s', e.args)
719
717
        if getattr(e, 'errno', None) is not None:
720
718
            mutter('Raising exception with errno %s', e.errno)