156
157
super(SFTPTransport, self).__init__(base,
157
158
_from_transport=_from_transport)
160
def close_file_stream(self, relpath):
161
"""See Transport.close_file_stream."""
162
handle = _file_streams.pop(self.abspath(relpath))
159
165
def _remote_path(self, relpath):
160
166
"""Return the path to be passed along the sftp protocol for relpath.
533
539
"""Create a directory at the given path."""
534
540
self._mkdir(self._remote_path(relpath), mode=mode)
542
def open_file_stream(self, relpath):
543
"""See Transport.open_file_stream."""
544
# initialise the file to zero-length
545
# this is three round trips, but we don't use this
546
# api more than once per write_group at the moment so
547
# it is a tolerable overhead. Better would be to truncate
548
# the file after opening. RBC 20070805
549
self.put_bytes_non_atomic(relpath, "")
550
abspath = self._remote_path(relpath)
551
# TODO: jam 20060816 paramiko doesn't publicly expose a way to
552
# set the file mode at create time. If it does, use it.
553
# But for now, we just chmod later anyway.
556
handle = self._get_sftp().file(abspath, mode='wb')
557
handle.set_pipelined(True)
558
except (paramiko.SSHException, IOError), e:
559
self._translate_io_exception(e, abspath,
561
_file_streams[self.abspath(relpath)] = handle
536
564
def _translate_io_exception(self, e, path, more_info='',
537
565
failure_exc=PathError):
538
566
"""Translate a paramiko or IOError into a friendlier exception.