~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-05-28 00:25:32 UTC
  • mfrom: (5264.1.2 command-help-bug-177500)
  • Revision ID: pqm@pqm.ubuntu.com-20100528002532-9bzj1fajyxckd1rg
(lifeless) Stop raising at runtime when a command has no help,
 instead have a test in the test suite that checks all known command objects.
 (Robert Collins)

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
 
117
123
    def unlock(self):
118
124
        if not self.lock_file:
119
125
            return
275
281
                    buffered = buffered[buffered_offset:]
276
282
                    buffered_data = [buffered]
277
283
                    buffered_len = len(buffered)
278
 
        # now that the data stream is done, close the handle
279
 
        fp.close()
280
284
        if buffered_len:
281
285
            buffered = ''.join(buffered_data)
282
286
            del buffered_data[:]
385
389
                                         self._host, self._port)
386
390
        return connection, (user, password)
387
391
 
388
 
    def disconnect(self):
389
 
        connection = self._get_connection()
390
 
        if connection is not None:
391
 
            connection.close()
392
 
 
393
392
    def _get_sftp(self):
394
393
        """Ensures that a connection is established"""
395
394
        connection = self._get_connection()
417
416
        :param relpath: The relative path to the file
418
417
        """
419
418
        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
420
424
            path = self._remote_path(relpath)
421
425
            f = self._get_sftp().file(path, mode='rb')
422
426
            if self._do_prefetch and (getattr(f, 'prefetch', None) is not None):
711
715
            if (e.args[0].startswith('Directory not empty: ')
712
716
                or getattr(e, 'errno', None) == errno.ENOTEMPTY):
713
717
                raise errors.DirectoryNotEmpty(path, str(e))
714
 
            if e.args == ('Operation unsupported',):
715
 
                raise errors.TransportNotPossible()
716
718
            mutter('Raising exception with args %s', e.args)
717
719
        if getattr(e, 'errno', None) is not None:
718
720
            mutter('Raising exception with errno %s', e.errno)