60
63
ConnectedTransport,
66
# Disable one particular warning that comes from paramiko in Python2.5; if
67
# this is emitted at the wrong time it tends to cause spurious test failures
68
# or at least noise in the test case::
70
# [1770/7639 in 86s, 1 known failures, 50 skipped, 2 missing features]
71
# test_permissions.TestSftpPermissions.test_new_files
72
# /var/lib/python-support/python2.5/paramiko/message.py:226: DeprecationWarning: integer argument expected, got float
73
# self.packet.write(struct.pack('>I', n))
74
warnings.filterwarnings('ignore',
75
'integer argument expected, got float',
76
category=DeprecationWarning,
77
module='paramiko.message')
65
81
except ImportError, e:
257
266
except (IOError, paramiko.SSHException), e:
258
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.
260
277
def _sftp_readv(self, fp, offsets, relpath='<unknown>'):
261
278
"""Use the readv() member of fp to do async readv.
525
542
"""Create a directory at the given path."""
526
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)
528
567
def _translate_io_exception(self, e, path, more_info='',
529
568
failure_exc=PathError):
530
569
"""Translate a paramiko or IOError into a friendlier exception.