ssh2.sftp_handle¶
SFTP handle, attributes and stat VFS classes.
-
class
ssh2.sftp_handle.
SFTPHandle
¶ -
close
(self)¶ Close handle. Called automatically when object is deleted and/or garbage collected.
- Return type
-
fsetstat
(self, SFTPAttributes attrs)¶ Set file handle attributes.
- Parameters
attrs (
ssh2.sftp.SFTPAttributes
) – Attributes to set.
-
fstat
(self)¶ Get file stat attributes from handle.
- Return type
tuple(int,
ssh2.sftp.SFTPAttributes
)
-
fstat_ex
(self, SFTPAttributes attrs, int setstat)¶ Get or set file attributes. Clients would typically use one of the fstat or fsetstat functions instead
-
fstatvfs
(self)¶ Get file system statistics for handle
- Return type
ssh2.sftp.SFTPStatVFS
-
read
(self, size_t buffer_maxlen=c_ssh2.LIBSSH2_CHANNEL_WINDOW_DEFAULT)¶ Read buffer from file handle.
-
readdir
(self, size_t buffer_maxlen=1024)¶ Get directory listing from file handle, if any.
This function is a generator and should be iterated on.
File handle must be opened with
ssh2.sftp.SFTP.readdir()
- Parameters
buffer_maxlen – Max length of returned file entry.
- Return type
iter(bytes)
-
readdir_ex
(self, size_t longentry_maxlen=1024, size_t buffer_maxlen=1024)¶ Get directory listing from file handle, if any.
File handle must be opened with
ssh2.sftp.SFTP.readdir()
This function is a generator and should be iterated on.
- Parameters
buffer_maxlen – Max length of returned buffer.
longentry_maxlen – Max length of file list entry.
- Return type
-
seek
(self, size_t offset)¶ Deprecated, use seek64.
Seek file to given offset.
-
seek64
(self, libssh2_uint64_t offset)¶ Seek file to given 64-bit offset.
-
write
(self, bytes buf)¶ Write buffer to file handle.
Returns tuple of (
error code
,bytes written
).In blocking mode
bytes_written
will always equallen(buf)
if no errors have occurred which would raise exception.In non-blocking mode
error_code
can be LIBSSH2_ERROR_EAGAIN andbytes_written
can be less thanlen(buf)
.Clients should resume from that point on next call to
write
, iebuf[bytes_written_in_last_call:]
.
-
-
class
ssh2.sftp_handle.
SFTPStatVFS
¶ File system statistics
-
f_bavail
¶ Free blocks for non-root
-
f_bfree
¶ Free blocks
-
f_blocks
¶ Size of fs in f_frsize units
-
f_bsize
¶ File system block size
-
f_favail
¶ Free inodes for non-root
-
f_ffree
¶ Free inodes
-
f_files
¶ Inodes
-
f_flag
¶ File system mount flags.
This property is a bit mask with defined bits
LIBSSH2_SFTP_ST_RDONLY
andLIBSSH2_SFTP_ST_NOSUID
-
f_frsize
¶ Fragment size
-
f_fsid
¶ File system ID
-
f_namemax
¶ Maximum filename length
-