~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: 2011-04-18 04:55:00 UTC
  • mfrom: (5784.2.1 754188-apport-test)
  • Revision ID: pqm@pqm.ubuntu.com-20110418045500-ce6lkgyiq7f47q43
(mbp) Rewrite test_report_bug_legacy away from using doctest (see bug
 764188) (Martin Pool)

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[:]
417
421
        :param relpath: The relative path to the file
418
422
        """
419
423
        try:
 
424
            # FIXME: by returning the file directly, we don't pass this
 
425
            # through to report_activity.  We could try wrapping the object
 
426
            # before it's returned.  For readv and get_bytes it's handled in
 
427
            # the higher-level function.
 
428
            # -- mbp 20090126
420
429
            path = self._remote_path(relpath)
421
430
            f = self._get_sftp().file(path, mode='rb')
422
431
            if self._do_prefetch and (getattr(f, 'prefetch', None) is not None):