264
266
except (IOError, paramiko.SSHException), e:
265
267
self._translate_io_exception(e, path, ': error retrieving')
269
def recommended_page_size(self):
270
"""See Transport.recommended_page_size().
272
For SFTP we suggest a large page size to reduce the overhead
273
introduced by latency.
267
277
def _sftp_readv(self, fp, offsets, relpath='<unknown>'):
268
278
"""Use the readv() member of fp to do async readv.
532
542
"""Create a directory at the given path."""
533
543
self._mkdir(self._remote_path(relpath), mode=mode)
545
def open_write_stream(self, relpath, mode=None):
546
"""See Transport.open_write_stream."""
547
# initialise the file to zero-length
548
# this is three round trips, but we don't use this
549
# api more than once per write_group at the moment so
550
# it is a tolerable overhead. Better would be to truncate
551
# the file after opening. RBC 20070805
552
self.put_bytes_non_atomic(relpath, "", mode)
553
abspath = self._remote_path(relpath)
554
# TODO: jam 20060816 paramiko doesn't publicly expose a way to
555
# set the file mode at create time. If it does, use it.
556
# But for now, we just chmod later anyway.
559
handle = self._get_sftp().file(abspath, mode='wb')
560
handle.set_pipelined(True)
561
except (paramiko.SSHException, IOError), e:
562
self._translate_io_exception(e, abspath,
564
_file_streams[self.abspath(relpath)] = handle
565
return FileFileStream(self, relpath, handle)
535
567
def _translate_io_exception(self, e, path, more_info='',
536
568
failure_exc=PathError):
537
569
"""Translate a paramiko or IOError into a friendlier exception.