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:
ssh2.sftp.SFTPAttributesor LIBSSH2_ERROR_EAGAIN
- 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:
- rewind(self)
Rewind file handle to beginning of file.
- Return type:
None
- seek(self, size_t offset)
Deprecated, use seek64.
Seek file to given offset.
- Parameters:
offset (int) – Offset to seek to.
- Return type:
None
- seek64(self, libssh2_uint64_t offset)
Seek file to given 64-bit offset.
- Parameters:
offset (int) – Offset to seek to.
- Return type:
None
- write(self, bytes buf)
Write buffer to file handle.
Returns tuple of (
error code,bytes written).In blocking mode
bytes_writtenwill always equallen(buf)if no errors have occurred which would raise exception.In non-blocking mode
error_codecan be LIBSSH2_ERROR_EAGAIN andbytes_writtencan 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_RDONLYandLIBSSH2_SFTP_ST_NOSUID
- f_frsize
Fragment size
- f_fsid
File system ID
- f_namemax
Maximum filename length