Utility Functions¶
- ssh2.utils.find_eol(bytes buf, Py_ssize_t pos)¶
- Find end-of-line in buffer from position and return end position of
line and where next find_eol should start from.
Eg - find_eol(b’line
- line2’, 0) would return (5, 6), next call should be
find_eol(b’line
- line2’, 6) for next line where 6 was added to previous
position.
- param buf
Data buffer to parse for line.
- type buf
bytes
- param pos
Starting position to parse from
- type pos
int
- rtype
(int, int)
- ssh2.utils.handle_error_codes(int errcode) int ¶
Raise appropriate exception for given error code.
Returns 0 on no error and
LIBSSH2_ERROR_EAGAIN
onEAGAIN
.- Raises
Appropriate exception from
ssh2.exceptions
.- Parameters
errcode – Error code as returned by
ssh2.session.Session.last_errno()
- ssh2.utils.ssh2_exit()¶
Call libssh2_exit
- ssh2.utils.version(int required_version=0)¶
Get libssh2 version string.
Passing in a non-zero required_version causes the function to return None if version is less than required_version
- Parameters
required_version (int) – Minimum required version
- ssh2.utils.wait_socket(_socket, Session session, timeout=1)¶
Helper function for testing non-blocking mode.
This function blocks the calling thread for <timeout> seconds - to be used only for testing purposes.