diff --git a/.appveyor.yml b/.appveyor.yml index bffed7e..fc77fc6 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -3,6 +3,7 @@ build: parallel: true verbosity: minimal skip_branch_with_pr: true +image: Visual Studio 2019 environment: global: @@ -13,12 +14,11 @@ environment: PYPI_PASS: secure: uXkrTaPGSNQdXTJIt3aiy2E1GBnbn6gH3opi7DgMIcmpLgZt7RTeqsaszbjPToGkoqfVXN+jdkQca4LfGAKZ8a2LgrrVYoITdxbjNkZB3yDBKk6ULNMsqdHmt4I1evRhSPSSZnRKU2rSzL+gOTViEVnhcahsUJPgNAIFvpZWsZfdRAafFtF1D33B03aAPwuhYuZTIwRyhUrwVGsYzOzIoDLtnpGj/0+GHazwjhHXfg/yTd600SPiWVsgknxjoeBu+cmi2iMDeT3ULu3P8UGjuQ== # Default python version to run single commands with - PYTHON_DEF: "C:\\Python36-x64" - PYTHON_VERSION: "3.6" + PYTHON_DEF: "C:\\Python38-x64" + PYTHON_VERSION: "3.8" # Python versions to build wheels for - PYTHONVERS: C:\Python36-x64 C:\Python37-x64 C:\Python38-x64 + PYTHONVERS: C:\Python36-x64 C:\Python37-x64 C:\Python38-x64 C:\Python39-x64 PYTHON_ARCH: "64" - MSVC: "Visual Studio 14 Win64" install: # If there is a newer build queued for the same PR, cancel this one. diff --git a/.gitignore b/.gitignore index 8899ac3..805dd33 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ libssh/compile_commands.json wheelhouse .idea tests/unit_test_cert_key-cert.pub +doc/_build diff --git a/Changelog.rst b/Changelog.rst index a15e4f5..30f6143 100644 --- a/Changelog.rst +++ b/Changelog.rst @@ -1,6 +1,28 @@ Change Log ============= +0.9.0 ++++++ + +Changes +------- + +* ``ssh.Channel.write`` and ``write_stderr`` now return return code and bytes written tuples. + + +Fixes +----- + +* ``ssh.key.generate`` could not be used. +* Key types in ``ssh.keytypes`` were not initialised correctly. + + +Packaging +--------- + +* Added Windows Python 3.9 binary wheel. + + 0.8.0 +++++ diff --git a/ci/appveyor/build_ssh.bat b/ci/appveyor/build_ssh.bat index 58ffda9..a645cc7 100755 --- a/ci/appveyor/build_ssh.bat +++ b/ci/appveyor/build_ssh.bat @@ -3,9 +3,8 @@ IF "%PYTHON_VERSION%" == "2.7" (exit 0) mkdir src cd src -set CMAKE_PLATFORM="%MSVC%" - -cmake ..\libssh -G %CMAKE_PLATFORM% ^ +cmake ..\libssh ^ + -A x64 ^ -DCMAKE_BUILD_TYPE=Release ^ -DZLIB_LIBRARY=C:/zlib/lib/zlibstatic.lib ^ -DZLIB_INCLUDE_DIR=C:/zlib/include ^ diff --git a/ci/appveyor/build_zlib.bat b/ci/appveyor/build_zlib.bat index 5ff4806..f11fe41 100755 --- a/ci/appveyor/build_zlib.bat +++ b/ci/appveyor/build_zlib.bat @@ -2,19 +2,11 @@ IF "%PYTHON_VERSION%" == "2.7" (exit 0) mkdir zlib_build && cd zlib_build -IF "%MSVC%" == "Visual Studio 9" ( - ECHO "Building without platform set" - cmake ..\zlib-1.2.11 -G "NMake Makefiles" ^ - -DCMAKE_INSTALL_PREFIX="C:\zlib" ^ - -DCMAKE_BUILD_TYPE=Release ^ - -DBUILD_SHARED_LIBS=OFF -) ELSE ( - ECHO "Building with platform %MSVC%" - cmake ..\zlib-1.2.11 ^ - -G"%MSVC%" ^ - -DCMAKE_INSTALL_PREFIX="C:\zlib" ^ - -DCMAKE_BUILD_TYPE=Release ^ - -DBUILD_SHARED_LIBS=OFF +cmake ..\zlib-1.2.11 ^ + -A x64 ^ + -DCMAKE_INSTALL_PREFIX="C:\zlib" ^ + -DCMAKE_BUILD_TYPE=Release ^ + -DBUILD_SHARED_LIBS=OFF ) cmake --build . --config Release --target install diff --git a/ssh/channel.c b/ssh/channel.c index c4df4b7..53349f5 100644 --- a/ssh/channel.c +++ b/ssh/channel.c @@ -6651,7 +6651,7 @@ static PyObject *__pyx_pf_3ssh_7channel_7Channel_64set_counter(CYTHON_UNUSED str * def set_counter(self, counter): * raise NotImplementedError # <<<<<<<<<<<<<< * - * def write(self, bytes data): + * def write(self, data not None): */ __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); __PYX_ERR(0, 298, __pyx_L1_error) @@ -6676,14 +6676,14 @@ static PyObject *__pyx_pf_3ssh_7channel_7Channel_64set_counter(CYTHON_UNUSED str /* "ssh/channel.pyx":300 * raise NotImplementedError * - * def write(self, bytes data): # <<<<<<<<<<<<<< - * cdef c_ssh.uint32_t size = len(data) - * cdef const_char *c_data = data + * def write(self, data not None): # <<<<<<<<<<<<<< + * """Write data to stdin on channel. + * */ /* Python wrapper */ static PyObject *__pyx_pw_3ssh_7channel_7Channel_67write(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/ -static char __pyx_doc_3ssh_7channel_7Channel_66write[] = "Channel.write(self, bytes data)"; +static char __pyx_doc_3ssh_7channel_7Channel_66write[] = "Channel.write(self, data)\nWrite data to stdin on channel.\n\n :param data: Data to write.\n :type data: str or bytes\n :returns: Return code and bytes written tuples.\n :rtype: (int, int)\n "; static PyObject *__pyx_pw_3ssh_7channel_7Channel_67write(PyObject *__pyx_v_self, PyObject *__pyx_v_data) { int __pyx_lineno = 0; const char *__pyx_filename = NULL; @@ -6691,8 +6691,10 @@ static PyObject *__pyx_pw_3ssh_7channel_7Channel_67write(PyObject *__pyx_v_self, PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), (&PyBytes_Type), 1, "data", 1))) __PYX_ERR(0, 300, __pyx_L1_error) - __pyx_r = __pyx_pf_3ssh_7channel_7Channel_66write(((struct __pyx_obj_3ssh_7channel_Channel *)__pyx_v_self), ((PyObject*)__pyx_v_data)); + if (unlikely(((PyObject *)__pyx_v_data) == Py_None)) { + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "data"); __PYX_ERR(0, 300, __pyx_L1_error) + } + __pyx_r = __pyx_pf_3ssh_7channel_7Channel_66write(((struct __pyx_obj_3ssh_7channel_Channel *)__pyx_v_self), ((PyObject *)__pyx_v_data)); /* function exit code */ goto __pyx_L0; @@ -6704,54 +6706,91 @@ static PyObject *__pyx_pw_3ssh_7channel_7Channel_67write(PyObject *__pyx_v_self, } static PyObject *__pyx_pf_3ssh_7channel_7Channel_66write(struct __pyx_obj_3ssh_7channel_Channel *__pyx_v_self, PyObject *__pyx_v_data) { - uint32_t __pyx_v_size; - const char *__pyx_v_c_data; + PyObject *__pyx_v_b_buf = 0; + char const *__pyx_v__buf; + uint32_t __pyx_v_buf_remainder; + uint32_t __pyx_v_buf_tot_size; + uint32_t __pyx_v_bytes_written; int __pyx_v_rc; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - const char *__pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_1 = NULL; + char const *__pyx_t_2; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write", 0); - /* "ssh/channel.pyx":301 - * - * def write(self, bytes data): - * cdef c_ssh.uint32_t size = len(data) # <<<<<<<<<<<<<< - * cdef const_char *c_data = data - * cdef int rc + /* "ssh/channel.pyx":308 + * :rtype: (int, int) + * """ + * cdef bytes b_buf = to_bytes(data) # <<<<<<<<<<<<<< + * cdef const char *_buf = b_buf + * cdef c_ssh.uint32_t buf_remainder = len(b_buf) + */ + __pyx_t_1 = __pyx_f_3ssh_5utils_to_bytes(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_b_buf = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "ssh/channel.pyx":309 + * """ + * cdef bytes b_buf = to_bytes(data) + * cdef const char *_buf = b_buf # <<<<<<<<<<<<<< + * cdef c_ssh.uint32_t buf_remainder = len(b_buf) + * cdef c_ssh.uint32_t buf_tot_size = buf_remainder + */ + if (unlikely(__pyx_v_b_buf == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 309, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 309, __pyx_L1_error) + __pyx_v__buf = __pyx_t_2; + + /* "ssh/channel.pyx":310 + * cdef bytes b_buf = to_bytes(data) + * cdef const char *_buf = b_buf + * cdef c_ssh.uint32_t buf_remainder = len(b_buf) # <<<<<<<<<<<<<< + * cdef c_ssh.uint32_t buf_tot_size = buf_remainder + * cdef c_ssh.uint32_t bytes_written = 0 */ - if (unlikely(__pyx_v_data == Py_None)) { + if (unlikely(__pyx_v_b_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 301, __pyx_L1_error) + __PYX_ERR(0, 310, __pyx_L1_error) } - __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_data); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 301, __pyx_L1_error) - __pyx_v_size = __pyx_t_1; + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 310, __pyx_L1_error) + __pyx_v_buf_remainder = __pyx_t_3; - /* "ssh/channel.pyx":302 - * def write(self, bytes data): - * cdef c_ssh.uint32_t size = len(data) - * cdef const_char *c_data = data # <<<<<<<<<<<<<< + /* "ssh/channel.pyx":311 + * cdef const char *_buf = b_buf + * cdef c_ssh.uint32_t buf_remainder = len(b_buf) + * cdef c_ssh.uint32_t buf_tot_size = buf_remainder # <<<<<<<<<<<<<< + * cdef c_ssh.uint32_t bytes_written = 0 + * cdef int rc + */ + __pyx_v_buf_tot_size = __pyx_v_buf_remainder; + + /* "ssh/channel.pyx":312 + * cdef c_ssh.uint32_t buf_remainder = len(b_buf) + * cdef c_ssh.uint32_t buf_tot_size = buf_remainder + * cdef c_ssh.uint32_t bytes_written = 0 # <<<<<<<<<<<<<< * cdef int rc * with nogil: */ - if (unlikely(__pyx_v_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 302, __pyx_L1_error) - } - __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_data); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 302, __pyx_L1_error) - __pyx_v_c_data = __pyx_t_2; + __pyx_v_bytes_written = 0; - /* "ssh/channel.pyx":304 - * cdef const_char *c_data = data + /* "ssh/channel.pyx":314 + * cdef c_ssh.uint32_t bytes_written = 0 * cdef int rc * with nogil: # <<<<<<<<<<<<<< - * rc = c_ssh.ssh_channel_write(self._channel, c_data, size) - * return handle_error_codes(rc, self._session._session) + * while buf_remainder > 0: + * rc = c_ssh.ssh_channel_write( */ { #ifdef WITH_THREAD @@ -6761,22 +6800,185 @@ static PyObject *__pyx_pf_3ssh_7channel_7Channel_66write(struct __pyx_obj_3ssh_7 #endif /*try:*/ { - /* "ssh/channel.pyx":305 + /* "ssh/channel.pyx":315 * cdef int rc * with nogil: - * rc = c_ssh.ssh_channel_write(self._channel, c_data, size) # <<<<<<<<<<<<<< - * return handle_error_codes(rc, self._session._session) + * while buf_remainder > 0: # <<<<<<<<<<<<<< + * rc = c_ssh.ssh_channel_write( + * self._channel, _buf, buf_remainder) + */ + while (1) { + __pyx_t_4 = ((__pyx_v_buf_remainder > 0) != 0); + if (!__pyx_t_4) break; + + /* "ssh/channel.pyx":316 + * with nogil: + * while buf_remainder > 0: + * rc = c_ssh.ssh_channel_write( # <<<<<<<<<<<<<< + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh.SSH_AGAIN: + */ + __pyx_v_rc = ssh_channel_write(__pyx_v_self->_channel, __pyx_v__buf, __pyx_v_buf_remainder); + + /* "ssh/channel.pyx":318 + * rc = c_ssh.ssh_channel_write( + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh.SSH_AGAIN: # <<<<<<<<<<<<<< + * with gil: + * return handle_error_codes( + */ + __pyx_t_5 = ((__pyx_v_rc < 0) != 0); + if (__pyx_t_5) { + } else { + __pyx_t_4 = __pyx_t_5; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_5 = ((__pyx_v_rc != SSH_AGAIN) != 0); + __pyx_t_4 = __pyx_t_5; + __pyx_L9_bool_binop_done:; + if (__pyx_t_4) { + + /* "ssh/channel.pyx":319 + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh.SSH_AGAIN: + * with gil: # <<<<<<<<<<<<<< + * return handle_error_codes( + * rc, self._session._session) + */ + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + /*try:*/ { + + /* "ssh/channel.pyx":320 + * if rc < 0 and rc != c_ssh.SSH_AGAIN: + * with gil: + * return handle_error_codes( # <<<<<<<<<<<<<< + * rc, self._session._session) + * elif rc == c_ssh.SSH_AGAIN: + */ + __Pyx_XDECREF(__pyx_r); + + /* "ssh/channel.pyx":321 + * with gil: + * return handle_error_codes( + * rc, self._session._session) # <<<<<<<<<<<<<< + * elif rc == c_ssh.SSH_AGAIN: + * break + */ + __pyx_t_6 = __pyx_f_3ssh_5utils_handle_error_codes(__pyx_v_rc, __pyx_v_self->_session->_session); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 320, __pyx_L14_error) + + /* "ssh/channel.pyx":320 + * if rc < 0 and rc != c_ssh.SSH_AGAIN: + * with gil: + * return handle_error_codes( # <<<<<<<<<<<<<< + * rc, self._session._session) + * elif rc == c_ssh.SSH_AGAIN: + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L13_return; + } + + /* "ssh/channel.pyx":319 + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh.SSH_AGAIN: + * with gil: # <<<<<<<<<<<<<< + * return handle_error_codes( + * rc, self._session._session) + */ + /*finally:*/ { + __pyx_L13_return: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L3_return; + } + __pyx_L14_error: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L4_error; + } + } + } + + /* "ssh/channel.pyx":318 + * rc = c_ssh.ssh_channel_write( + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh.SSH_AGAIN: # <<<<<<<<<<<<<< + * with gil: + * return handle_error_codes( + */ + } + + /* "ssh/channel.pyx":322 + * return handle_error_codes( + * rc, self._session._session) + * elif rc == c_ssh.SSH_AGAIN: # <<<<<<<<<<<<<< + * break + * _buf += rc + */ + __pyx_t_4 = ((__pyx_v_rc == SSH_AGAIN) != 0); + if (__pyx_t_4) { + + /* "ssh/channel.pyx":323 + * rc, self._session._session) + * elif rc == c_ssh.SSH_AGAIN: + * break # <<<<<<<<<<<<<< + * _buf += rc + * buf_remainder -= rc + */ + goto __pyx_L7_break; + + /* "ssh/channel.pyx":322 + * return handle_error_codes( + * rc, self._session._session) + * elif rc == c_ssh.SSH_AGAIN: # <<<<<<<<<<<<<< + * break + * _buf += rc + */ + } + + /* "ssh/channel.pyx":324 + * elif rc == c_ssh.SSH_AGAIN: + * break + * _buf += rc # <<<<<<<<<<<<<< + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder + */ + __pyx_v__buf = (__pyx_v__buf + __pyx_v_rc); + + /* "ssh/channel.pyx":325 + * break + * _buf += rc + * buf_remainder -= rc # <<<<<<<<<<<<<< + * bytes_written = buf_tot_size - buf_remainder + * return rc, bytes_written + */ + __pyx_v_buf_remainder = (__pyx_v_buf_remainder - __pyx_v_rc); + } + __pyx_L7_break:; + + /* "ssh/channel.pyx":326 + * _buf += rc + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder # <<<<<<<<<<<<<< + * return rc, bytes_written * */ - __pyx_v_rc = ssh_channel_write(__pyx_v_self->_channel, __pyx_v_c_data, __pyx_v_size); + __pyx_v_bytes_written = (__pyx_v_buf_tot_size - __pyx_v_buf_remainder); } - /* "ssh/channel.pyx":304 - * cdef const_char *c_data = data + /* "ssh/channel.pyx":314 + * cdef c_ssh.uint32_t bytes_written = 0 * cdef int rc * with nogil: # <<<<<<<<<<<<<< - * rc = c_ssh.ssh_channel_write(self._channel, c_data, size) - * return handle_error_codes(rc, self._session._session) + * while buf_remainder > 0: + * rc = c_ssh.ssh_channel_write( */ /*finally:*/ { /*normal exit:*/{ @@ -6786,55 +6988,81 @@ static PyObject *__pyx_pf_3ssh_7channel_7Channel_66write(struct __pyx_obj_3ssh_7 #endif goto __pyx_L5; } + __pyx_L3_return: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L0; + } + __pyx_L4_error: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L1_error; + } __pyx_L5:; } } - /* "ssh/channel.pyx":306 - * with nogil: - * rc = c_ssh.ssh_channel_write(self._channel, c_data, size) - * return handle_error_codes(rc, self._session._session) # <<<<<<<<<<<<<< + /* "ssh/channel.pyx":327 + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder + * return rc, bytes_written # <<<<<<<<<<<<<< * - * def write_stderr(self, bytes data): + * def write_stderr(self, data not None): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_f_3ssh_5utils_handle_error_codes(__pyx_v_rc, __pyx_v_self->_session->_session); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 306, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyInt_From_uint32_t(__pyx_v_bytes_written); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 327, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 327, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); + __pyx_t_1 = 0; + __pyx_t_7 = 0; + __pyx_r = __pyx_t_8; + __pyx_t_8 = 0; goto __pyx_L0; /* "ssh/channel.pyx":300 * raise NotImplementedError * - * def write(self, bytes data): # <<<<<<<<<<<<<< - * cdef c_ssh.uint32_t size = len(data) - * cdef const_char *c_data = data + * def write(self, data not None): # <<<<<<<<<<<<<< + * """Write data to stdin on channel. + * */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("ssh.channel.Channel.write", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_b_buf); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "ssh/channel.pyx":308 - * return handle_error_codes(rc, self._session._session) +/* "ssh/channel.pyx":329 + * return rc, bytes_written + * + * def write_stderr(self, data not None): # <<<<<<<<<<<<<< + * """Write data to stderr. * - * def write_stderr(self, bytes data): # <<<<<<<<<<<<<< - * cdef c_ssh.uint32_t size = len(data) - * cdef const_char *c_data = data */ /* Python wrapper */ static PyObject *__pyx_pw_3ssh_7channel_7Channel_69write_stderr(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/ -static char __pyx_doc_3ssh_7channel_7Channel_68write_stderr[] = "Channel.write_stderr(self, bytes data)"; +static char __pyx_doc_3ssh_7channel_7Channel_68write_stderr[] = "Channel.write_stderr(self, data)\nWrite data to stderr.\n\n :param data: Data to write.\n :type data: str or bytes\n :returns: Return code and bytes written tuples.\n :rtype: (int, int)\n "; static PyObject *__pyx_pw_3ssh_7channel_7Channel_69write_stderr(PyObject *__pyx_v_self, PyObject *__pyx_v_data) { int __pyx_lineno = 0; const char *__pyx_filename = NULL; @@ -6842,8 +7070,10 @@ static PyObject *__pyx_pw_3ssh_7channel_7Channel_69write_stderr(PyObject *__pyx_ PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("write_stderr (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), (&PyBytes_Type), 1, "data", 1))) __PYX_ERR(0, 308, __pyx_L1_error) - __pyx_r = __pyx_pf_3ssh_7channel_7Channel_68write_stderr(((struct __pyx_obj_3ssh_7channel_Channel *)__pyx_v_self), ((PyObject*)__pyx_v_data)); + if (unlikely(((PyObject *)__pyx_v_data) == Py_None)) { + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "data"); __PYX_ERR(0, 329, __pyx_L1_error) + } + __pyx_r = __pyx_pf_3ssh_7channel_7Channel_68write_stderr(((struct __pyx_obj_3ssh_7channel_Channel *)__pyx_v_self), ((PyObject *)__pyx_v_data)); /* function exit code */ goto __pyx_L0; @@ -6855,54 +7085,91 @@ static PyObject *__pyx_pw_3ssh_7channel_7Channel_69write_stderr(PyObject *__pyx_ } static PyObject *__pyx_pf_3ssh_7channel_7Channel_68write_stderr(struct __pyx_obj_3ssh_7channel_Channel *__pyx_v_self, PyObject *__pyx_v_data) { - uint32_t __pyx_v_size; - const char *__pyx_v_c_data; + PyObject *__pyx_v_b_buf = 0; + char const *__pyx_v__buf; + uint32_t __pyx_v_buf_remainder; + uint32_t __pyx_v_buf_tot_size; + uint32_t __pyx_v_bytes_written; int __pyx_v_rc; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations - Py_ssize_t __pyx_t_1; - const char *__pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; + PyObject *__pyx_t_1 = NULL; + char const *__pyx_t_2; + Py_ssize_t __pyx_t_3; + int __pyx_t_4; + int __pyx_t_5; + int __pyx_t_6; + PyObject *__pyx_t_7 = NULL; + PyObject *__pyx_t_8 = NULL; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("write_stderr", 0); - /* "ssh/channel.pyx":309 - * - * def write_stderr(self, bytes data): - * cdef c_ssh.uint32_t size = len(data) # <<<<<<<<<<<<<< - * cdef const_char *c_data = data - * cdef int rc + /* "ssh/channel.pyx":337 + * :rtype: (int, int) + * """ + * cdef bytes b_buf = to_bytes(data) # <<<<<<<<<<<<<< + * cdef const char *_buf = b_buf + * cdef c_ssh.uint32_t buf_remainder = len(b_buf) */ - if (unlikely(__pyx_v_data == Py_None)) { + __pyx_t_1 = __pyx_f_3ssh_5utils_to_bytes(__pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_v_b_buf = ((PyObject*)__pyx_t_1); + __pyx_t_1 = 0; + + /* "ssh/channel.pyx":338 + * """ + * cdef bytes b_buf = to_bytes(data) + * cdef const char *_buf = b_buf # <<<<<<<<<<<<<< + * cdef c_ssh.uint32_t buf_remainder = len(b_buf) + * cdef c_ssh.uint32_t buf_tot_size = buf_remainder + */ + if (unlikely(__pyx_v_b_buf == Py_None)) { + PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); + __PYX_ERR(0, 338, __pyx_L1_error) + } + __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_b_buf); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 338, __pyx_L1_error) + __pyx_v__buf = __pyx_t_2; + + /* "ssh/channel.pyx":339 + * cdef bytes b_buf = to_bytes(data) + * cdef const char *_buf = b_buf + * cdef c_ssh.uint32_t buf_remainder = len(b_buf) # <<<<<<<<<<<<<< + * cdef c_ssh.uint32_t buf_tot_size = buf_remainder + * cdef c_ssh.uint32_t bytes_written = 0 + */ + if (unlikely(__pyx_v_b_buf == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 309, __pyx_L1_error) + __PYX_ERR(0, 339, __pyx_L1_error) } - __pyx_t_1 = PyBytes_GET_SIZE(__pyx_v_data); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 309, __pyx_L1_error) - __pyx_v_size = __pyx_t_1; + __pyx_t_3 = PyBytes_GET_SIZE(__pyx_v_b_buf); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 339, __pyx_L1_error) + __pyx_v_buf_remainder = __pyx_t_3; - /* "ssh/channel.pyx":310 - * def write_stderr(self, bytes data): - * cdef c_ssh.uint32_t size = len(data) - * cdef const_char *c_data = data # <<<<<<<<<<<<<< + /* "ssh/channel.pyx":340 + * cdef const char *_buf = b_buf + * cdef c_ssh.uint32_t buf_remainder = len(b_buf) + * cdef c_ssh.uint32_t buf_tot_size = buf_remainder # <<<<<<<<<<<<<< + * cdef c_ssh.uint32_t bytes_written = 0 + * cdef int rc + */ + __pyx_v_buf_tot_size = __pyx_v_buf_remainder; + + /* "ssh/channel.pyx":341 + * cdef c_ssh.uint32_t buf_remainder = len(b_buf) + * cdef c_ssh.uint32_t buf_tot_size = buf_remainder + * cdef c_ssh.uint32_t bytes_written = 0 # <<<<<<<<<<<<<< * cdef int rc * with nogil: */ - if (unlikely(__pyx_v_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found"); - __PYX_ERR(0, 310, __pyx_L1_error) - } - __pyx_t_2 = __Pyx_PyBytes_AsString(__pyx_v_data); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) __PYX_ERR(0, 310, __pyx_L1_error) - __pyx_v_c_data = __pyx_t_2; + __pyx_v_bytes_written = 0; - /* "ssh/channel.pyx":312 - * cdef const_char *c_data = data + /* "ssh/channel.pyx":343 + * cdef c_ssh.uint32_t bytes_written = 0 * cdef int rc * with nogil: # <<<<<<<<<<<<<< - * rc = c_ssh.ssh_channel_write_stderr(self._channel, c_data, size) - * return handle_error_codes(rc, self._session._session) + * while buf_remainder > 0: + * rc = c_ssh.ssh_channel_write_stderr( */ { #ifdef WITH_THREAD @@ -6912,22 +7179,185 @@ static PyObject *__pyx_pf_3ssh_7channel_7Channel_68write_stderr(struct __pyx_obj #endif /*try:*/ { - /* "ssh/channel.pyx":313 + /* "ssh/channel.pyx":344 * cdef int rc * with nogil: - * rc = c_ssh.ssh_channel_write_stderr(self._channel, c_data, size) # <<<<<<<<<<<<<< - * return handle_error_codes(rc, self._session._session) + * while buf_remainder > 0: # <<<<<<<<<<<<<< + * rc = c_ssh.ssh_channel_write_stderr( + * self._channel, _buf, buf_remainder) + */ + while (1) { + __pyx_t_4 = ((__pyx_v_buf_remainder > 0) != 0); + if (!__pyx_t_4) break; + + /* "ssh/channel.pyx":345 + * with nogil: + * while buf_remainder > 0: + * rc = c_ssh.ssh_channel_write_stderr( # <<<<<<<<<<<<<< + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh.SSH_AGAIN: + */ + __pyx_v_rc = ssh_channel_write_stderr(__pyx_v_self->_channel, __pyx_v__buf, __pyx_v_buf_remainder); + + /* "ssh/channel.pyx":347 + * rc = c_ssh.ssh_channel_write_stderr( + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh.SSH_AGAIN: # <<<<<<<<<<<<<< + * with gil: + * return handle_error_codes( + */ + __pyx_t_5 = ((__pyx_v_rc < 0) != 0); + if (__pyx_t_5) { + } else { + __pyx_t_4 = __pyx_t_5; + goto __pyx_L9_bool_binop_done; + } + __pyx_t_5 = ((__pyx_v_rc != SSH_AGAIN) != 0); + __pyx_t_4 = __pyx_t_5; + __pyx_L9_bool_binop_done:; + if (__pyx_t_4) { + + /* "ssh/channel.pyx":348 + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh.SSH_AGAIN: + * with gil: # <<<<<<<<<<<<<< + * return handle_error_codes( + * rc, self._session._session) + */ + { + #ifdef WITH_THREAD + PyGILState_STATE __pyx_gilstate_save = __Pyx_PyGILState_Ensure(); + #endif + /*try:*/ { + + /* "ssh/channel.pyx":349 + * if rc < 0 and rc != c_ssh.SSH_AGAIN: + * with gil: + * return handle_error_codes( # <<<<<<<<<<<<<< + * rc, self._session._session) + * elif rc == c_ssh.SSH_AGAIN: + */ + __Pyx_XDECREF(__pyx_r); + + /* "ssh/channel.pyx":350 + * with gil: + * return handle_error_codes( + * rc, self._session._session) # <<<<<<<<<<<<<< + * elif rc == c_ssh.SSH_AGAIN: + * break + */ + __pyx_t_6 = __pyx_f_3ssh_5utils_handle_error_codes(__pyx_v_rc, __pyx_v_self->_session->_session); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 349, __pyx_L14_error) + + /* "ssh/channel.pyx":349 + * if rc < 0 and rc != c_ssh.SSH_AGAIN: + * with gil: + * return handle_error_codes( # <<<<<<<<<<<<<< + * rc, self._session._session) + * elif rc == c_ssh.SSH_AGAIN: + */ + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 349, __pyx_L14_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_r = __pyx_t_1; + __pyx_t_1 = 0; + goto __pyx_L13_return; + } + + /* "ssh/channel.pyx":348 + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh.SSH_AGAIN: + * with gil: # <<<<<<<<<<<<<< + * return handle_error_codes( + * rc, self._session._session) + */ + /*finally:*/ { + __pyx_L13_return: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L3_return; + } + __pyx_L14_error: { + #ifdef WITH_THREAD + __Pyx_PyGILState_Release(__pyx_gilstate_save); + #endif + goto __pyx_L4_error; + } + } + } + + /* "ssh/channel.pyx":347 + * rc = c_ssh.ssh_channel_write_stderr( + * self._channel, _buf, buf_remainder) + * if rc < 0 and rc != c_ssh.SSH_AGAIN: # <<<<<<<<<<<<<< + * with gil: + * return handle_error_codes( + */ + } + + /* "ssh/channel.pyx":351 + * return handle_error_codes( + * rc, self._session._session) + * elif rc == c_ssh.SSH_AGAIN: # <<<<<<<<<<<<<< + * break + * _buf += rc + */ + __pyx_t_4 = ((__pyx_v_rc == SSH_AGAIN) != 0); + if (__pyx_t_4) { + + /* "ssh/channel.pyx":352 + * rc, self._session._session) + * elif rc == c_ssh.SSH_AGAIN: + * break # <<<<<<<<<<<<<< + * _buf += rc + * buf_remainder -= rc + */ + goto __pyx_L7_break; + + /* "ssh/channel.pyx":351 + * return handle_error_codes( + * rc, self._session._session) + * elif rc == c_ssh.SSH_AGAIN: # <<<<<<<<<<<<<< + * break + * _buf += rc + */ + } + + /* "ssh/channel.pyx":353 + * elif rc == c_ssh.SSH_AGAIN: + * break + * _buf += rc # <<<<<<<<<<<<<< + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder + */ + __pyx_v__buf = (__pyx_v__buf + __pyx_v_rc); + + /* "ssh/channel.pyx":354 + * break + * _buf += rc + * buf_remainder -= rc # <<<<<<<<<<<<<< + * bytes_written = buf_tot_size - buf_remainder + * return rc, bytes_written + */ + __pyx_v_buf_remainder = (__pyx_v_buf_remainder - __pyx_v_rc); + } + __pyx_L7_break:; + + /* "ssh/channel.pyx":355 + * _buf += rc + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder # <<<<<<<<<<<<<< + * return rc, bytes_written * */ - __pyx_v_rc = ssh_channel_write_stderr(__pyx_v_self->_channel, __pyx_v_c_data, __pyx_v_size); + __pyx_v_bytes_written = (__pyx_v_buf_tot_size - __pyx_v_buf_remainder); } - /* "ssh/channel.pyx":312 - * cdef const_char *c_data = data + /* "ssh/channel.pyx":343 + * cdef c_ssh.uint32_t bytes_written = 0 * cdef int rc * with nogil: # <<<<<<<<<<<<<< - * rc = c_ssh.ssh_channel_write_stderr(self._channel, c_data, size) - * return handle_error_codes(rc, self._session._session) + * while buf_remainder > 0: + * rc = c_ssh.ssh_channel_write_stderr( */ /*finally:*/ { /*normal exit:*/{ @@ -6937,46 +7367,72 @@ static PyObject *__pyx_pf_3ssh_7channel_7Channel_68write_stderr(struct __pyx_obj #endif goto __pyx_L5; } + __pyx_L3_return: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L0; + } + __pyx_L4_error: { + #ifdef WITH_THREAD + __Pyx_FastGIL_Forget(); + Py_BLOCK_THREADS + #endif + goto __pyx_L1_error; + } __pyx_L5:; } } - /* "ssh/channel.pyx":314 - * with nogil: - * rc = c_ssh.ssh_channel_write_stderr(self._channel, c_data, size) - * return handle_error_codes(rc, self._session._session) # <<<<<<<<<<<<<< + /* "ssh/channel.pyx":356 + * buf_remainder -= rc + * bytes_written = buf_tot_size - buf_remainder + * return rc, bytes_written # <<<<<<<<<<<<<< * * def window_size(self): */ __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __pyx_f_3ssh_5utils_handle_error_codes(__pyx_v_rc, __pyx_v_self->_session->_session); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 314, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 314, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; + __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_1); + __pyx_t_7 = __Pyx_PyInt_From_uint32_t(__pyx_v_bytes_written); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_7); + __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 356, __pyx_L1_error) + __Pyx_GOTREF(__pyx_t_8); + __Pyx_GIVEREF(__pyx_t_1); + PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); + __Pyx_GIVEREF(__pyx_t_7); + PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7); + __pyx_t_1 = 0; + __pyx_t_7 = 0; + __pyx_r = __pyx_t_8; + __pyx_t_8 = 0; goto __pyx_L0; - /* "ssh/channel.pyx":308 - * return handle_error_codes(rc, self._session._session) + /* "ssh/channel.pyx":329 + * return rc, bytes_written + * + * def write_stderr(self, data not None): # <<<<<<<<<<<<<< + * """Write data to stderr. * - * def write_stderr(self, bytes data): # <<<<<<<<<<<<<< - * cdef c_ssh.uint32_t size = len(data) - * cdef const_char *c_data = data */ /* function exit code */ __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_4); + __Pyx_XDECREF(__pyx_t_1); + __Pyx_XDECREF(__pyx_t_7); + __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("ssh.channel.Channel.write_stderr", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; + __Pyx_XDECREF(__pyx_v_b_buf); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } -/* "ssh/channel.pyx":316 - * return handle_error_codes(rc, self._session._session) +/* "ssh/channel.pyx":358 + * return rc, bytes_written * * def window_size(self): # <<<<<<<<<<<<<< * cdef c_ssh.uint32_t size @@ -7007,7 +7463,7 @@ static PyObject *__pyx_pf_3ssh_7channel_7Channel_70window_size(struct __pyx_obj_ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("window_size", 0); - /* "ssh/channel.pyx":318 + /* "ssh/channel.pyx":360 * def window_size(self): * cdef c_ssh.uint32_t size * with nogil: # <<<<<<<<<<<<<< @@ -7022,7 +7478,7 @@ static PyObject *__pyx_pf_3ssh_7channel_7Channel_70window_size(struct __pyx_obj_ #endif /*try:*/ { - /* "ssh/channel.pyx":319 + /* "ssh/channel.pyx":361 * cdef c_ssh.uint32_t size * with nogil: * size = c_ssh.ssh_channel_window_size(self._channel) # <<<<<<<<<<<<<< @@ -7032,7 +7488,7 @@ static PyObject *__pyx_pf_3ssh_7channel_7Channel_70window_size(struct __pyx_obj_ __pyx_v_size = ssh_channel_window_size(__pyx_v_self->_channel); } - /* "ssh/channel.pyx":318 + /* "ssh/channel.pyx":360 * def window_size(self): * cdef c_ssh.uint32_t size * with nogil: # <<<<<<<<<<<<<< @@ -7051,7 +7507,7 @@ static PyObject *__pyx_pf_3ssh_7channel_7Channel_70window_size(struct __pyx_obj_ } } - /* "ssh/channel.pyx":320 + /* "ssh/channel.pyx":362 * with nogil: * size = c_ssh.ssh_channel_window_size(self._channel) * return size # <<<<<<<<<<<<<< @@ -7059,14 +7515,14 @@ static PyObject *__pyx_pf_3ssh_7channel_7Channel_70window_size(struct __pyx_obj_ * def select(self, channels not None, outchannels not None, maxfd, */ __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L1_error) + __pyx_t_1 = __Pyx_PyInt_From_uint32_t(__pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 362, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; - /* "ssh/channel.pyx":316 - * return handle_error_codes(rc, self._session._session) + /* "ssh/channel.pyx":358 + * return rc, bytes_written * * def window_size(self): # <<<<<<<<<<<<<< * cdef c_ssh.uint32_t size @@ -7084,7 +7540,7 @@ static PyObject *__pyx_pf_3ssh_7channel_7Channel_70window_size(struct __pyx_obj_ return __pyx_r; } -/* "ssh/channel.pyx":322 +/* "ssh/channel.pyx":364 * return size * * def select(self, channels not None, outchannels not None, maxfd, # <<<<<<<<<<<<<< @@ -7111,7 +7567,7 @@ static PyObject *__pyx_pw_3ssh_7channel_7Channel_73select(PyObject *__pyx_v_self static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_channels,&__pyx_n_s_outchannels,&__pyx_n_s_maxfd,&__pyx_n_s_readfds,&__pyx_n_s_timeout,0}; PyObject* values[5] = {0,0,0,0,0}; - /* "ssh/channel.pyx":323 + /* "ssh/channel.pyx":365 * * def select(self, channels not None, outchannels not None, maxfd, * readfds, timeout=None): # <<<<<<<<<<<<<< @@ -7144,19 +7600,19 @@ static PyObject *__pyx_pw_3ssh_7channel_7Channel_73select(PyObject *__pyx_v_self case 1: if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_outchannels)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("select", 0, 4, 5, 1); __PYX_ERR(0, 322, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("select", 0, 4, 5, 1); __PYX_ERR(0, 364, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_maxfd)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("select", 0, 4, 5, 2); __PYX_ERR(0, 322, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("select", 0, 4, 5, 2); __PYX_ERR(0, 364, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 3: if (likely((values[3] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_readfds)) != 0)) kw_args--; else { - __Pyx_RaiseArgtupleInvalid("select", 0, 4, 5, 3); __PYX_ERR(0, 322, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("select", 0, 4, 5, 3); __PYX_ERR(0, 364, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 4: @@ -7166,7 +7622,7 @@ static PyObject *__pyx_pw_3ssh_7channel_7Channel_73select(PyObject *__pyx_v_self } } if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "select") < 0)) __PYX_ERR(0, 322, __pyx_L3_error) + if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "select") < 0)) __PYX_ERR(0, 364, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { @@ -7188,21 +7644,21 @@ static PyObject *__pyx_pw_3ssh_7channel_7Channel_73select(PyObject *__pyx_v_self } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("select", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 322, __pyx_L3_error) + __Pyx_RaiseArgtupleInvalid("select", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 364, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("ssh.channel.Channel.select", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(((PyObject *)__pyx_v_channels) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "channels"); __PYX_ERR(0, 322, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "channels"); __PYX_ERR(0, 364, __pyx_L1_error) } if (unlikely(((PyObject *)__pyx_v_outchannels) == Py_None)) { - PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "outchannels"); __PYX_ERR(0, 322, __pyx_L1_error) + PyErr_Format(PyExc_TypeError, "Argument '%.200s' must not be None", "outchannels"); __PYX_ERR(0, 364, __pyx_L1_error) } __pyx_r = __pyx_pf_3ssh_7channel_7Channel_72select(((struct __pyx_obj_3ssh_7channel_Channel *)__pyx_v_self), __pyx_v_channels, __pyx_v_outchannels, __pyx_v_maxfd, __pyx_v_readfds, __pyx_v_timeout); - /* "ssh/channel.pyx":322 + /* "ssh/channel.pyx":364 * return size * * def select(self, channels not None, outchannels not None, maxfd, # <<<<<<<<<<<<<< @@ -7227,15 +7683,15 @@ static PyObject *__pyx_pf_3ssh_7channel_7Channel_72select(CYTHON_UNUSED struct _ int __pyx_clineno = 0; __Pyx_RefNannySetupContext("select", 0); - /* "ssh/channel.pyx":324 + /* "ssh/channel.pyx":366 * def select(self, channels not None, outchannels not None, maxfd, * readfds, timeout=None): * raise NotImplementedError # <<<<<<<<<<<<<< */ __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0); - __PYX_ERR(0, 324, __pyx_L1_error) + __PYX_ERR(0, 366, __pyx_L1_error) - /* "ssh/channel.pyx":322 + /* "ssh/channel.pyx":364 * return size * * def select(self, channels not None, outchannels not None, maxfd, # <<<<<<<<<<<<<< diff --git a/ssh/channel.pyx b/ssh/channel.pyx index cc0d6a0..c507a2d 100644 --- a/ssh/channel.pyx +++ b/ssh/channel.pyx @@ -297,21 +297,63 @@ cdef class Channel: def set_counter(self, counter): raise NotImplementedError - def write(self, bytes data): - cdef c_ssh.uint32_t size = len(data) - cdef const_char *c_data = data + def write(self, data not None): + """Write data to stdin on channel. + + :param data: Data to write. + :type data: str or bytes + :returns: Return code and bytes written tuples. + :rtype: (int, int) + """ + cdef bytes b_buf = to_bytes(data) + cdef const char *_buf = b_buf + cdef c_ssh.uint32_t buf_remainder = len(b_buf) + cdef c_ssh.uint32_t buf_tot_size = buf_remainder + cdef c_ssh.uint32_t bytes_written = 0 cdef int rc with nogil: - rc = c_ssh.ssh_channel_write(self._channel, c_data, size) - return handle_error_codes(rc, self._session._session) - - def write_stderr(self, bytes data): - cdef c_ssh.uint32_t size = len(data) - cdef const_char *c_data = data + while buf_remainder > 0: + rc = c_ssh.ssh_channel_write( + self._channel, _buf, buf_remainder) + if rc < 0 and rc != c_ssh.SSH_AGAIN: + with gil: + return handle_error_codes( + rc, self._session._session) + elif rc == c_ssh.SSH_AGAIN: + break + _buf += rc + buf_remainder -= rc + bytes_written = buf_tot_size - buf_remainder + return rc, bytes_written + + def write_stderr(self, data not None): + """Write data to stderr. + + :param data: Data to write. + :type data: str or bytes + :returns: Return code and bytes written tuples. + :rtype: (int, int) + """ + cdef bytes b_buf = to_bytes(data) + cdef const char *_buf = b_buf + cdef c_ssh.uint32_t buf_remainder = len(b_buf) + cdef c_ssh.uint32_t buf_tot_size = buf_remainder + cdef c_ssh.uint32_t bytes_written = 0 cdef int rc with nogil: - rc = c_ssh.ssh_channel_write_stderr(self._channel, c_data, size) - return handle_error_codes(rc, self._session._session) + while buf_remainder > 0: + rc = c_ssh.ssh_channel_write_stderr( + self._channel, _buf, buf_remainder) + if rc < 0 and rc != c_ssh.SSH_AGAIN: + with gil: + return handle_error_codes( + rc, self._session._session) + elif rc == c_ssh.SSH_AGAIN: + break + _buf += rc + buf_remainder -= rc + bytes_written = buf_tot_size - buf_remainder + return rc, bytes_written def window_size(self): cdef c_ssh.uint32_t size diff --git a/ssh/options.c b/ssh/options.c index ccdd494..234aa35 100644 --- a/ssh/options.c +++ b/ssh/options.c @@ -2993,7 +2993,7 @@ if (!__Pyx_RefNanny) { * PORT = Option.from_option(ssh_options_e.SSH_OPTIONS_PORT) * PORT_STR = Option.from_option(ssh_options_e.SSH_OPTIONS_PORT_STR) # <<<<<<<<<<<<<< * FD = Option.from_option(ssh_options_e.SSH_OPTIONS_FD) - * USER = Option.from_option(ssh_options_e.SSH_OPTIONS_USER) + * SSH_DIR = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH_DIR) */ __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_PORT_STR)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); @@ -3004,8 +3004,8 @@ if (!__Pyx_RefNanny) { * PORT = Option.from_option(ssh_options_e.SSH_OPTIONS_PORT) * PORT_STR = Option.from_option(ssh_options_e.SSH_OPTIONS_PORT_STR) * FD = Option.from_option(ssh_options_e.SSH_OPTIONS_FD) # <<<<<<<<<<<<<< - * USER = Option.from_option(ssh_options_e.SSH_OPTIONS_USER) * SSH_DIR = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH_DIR) + * IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_IDENTITY) */ __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_FD)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); @@ -3015,395 +3015,383 @@ if (!__Pyx_RefNanny) { /* "ssh/options.pyx":48 * PORT_STR = Option.from_option(ssh_options_e.SSH_OPTIONS_PORT_STR) * FD = Option.from_option(ssh_options_e.SSH_OPTIONS_FD) - * USER = Option.from_option(ssh_options_e.SSH_OPTIONS_USER) # <<<<<<<<<<<<<< - * SSH_DIR = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH_DIR) - * IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_IDENTITY) - */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_USER)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_USER, __pyx_t_1) < 0) __PYX_ERR(0, 48, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "ssh/options.pyx":49 - * FD = Option.from_option(ssh_options_e.SSH_OPTIONS_FD) - * USER = Option.from_option(ssh_options_e.SSH_OPTIONS_USER) * SSH_DIR = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH_DIR) # <<<<<<<<<<<<<< * IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_IDENTITY) * ADD_IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_ADD_IDENTITY) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_SSH_DIR)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_SSH_DIR)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_SSH_DIR, __pyx_t_1) < 0) __PYX_ERR(0, 49, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_SSH_DIR, __pyx_t_1) < 0) __PYX_ERR(0, 48, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":50 - * USER = Option.from_option(ssh_options_e.SSH_OPTIONS_USER) + /* "ssh/options.pyx":49 + * FD = Option.from_option(ssh_options_e.SSH_OPTIONS_FD) * SSH_DIR = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH_DIR) * IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_IDENTITY) # <<<<<<<<<<<<<< * ADD_IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_ADD_IDENTITY) * KNOWNHOSTS = Option.from_option(ssh_options_e.SSH_OPTIONS_KNOWNHOSTS) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_IDENTITY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_IDENTITY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_IDENTITY, __pyx_t_1) < 0) __PYX_ERR(0, 50, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_IDENTITY, __pyx_t_1) < 0) __PYX_ERR(0, 49, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":51 + /* "ssh/options.pyx":50 * SSH_DIR = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH_DIR) * IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_IDENTITY) * ADD_IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_ADD_IDENTITY) # <<<<<<<<<<<<<< * KNOWNHOSTS = Option.from_option(ssh_options_e.SSH_OPTIONS_KNOWNHOSTS) * TIMEOUT = Option.from_option(ssh_options_e.SSH_OPTIONS_TIMEOUT) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_ADD_IDENTITY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_ADD_IDENTITY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_ADD_IDENTITY, __pyx_t_1) < 0) __PYX_ERR(0, 51, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_ADD_IDENTITY, __pyx_t_1) < 0) __PYX_ERR(0, 50, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":52 + /* "ssh/options.pyx":51 * IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_IDENTITY) * ADD_IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_ADD_IDENTITY) * KNOWNHOSTS = Option.from_option(ssh_options_e.SSH_OPTIONS_KNOWNHOSTS) # <<<<<<<<<<<<<< * TIMEOUT = Option.from_option(ssh_options_e.SSH_OPTIONS_TIMEOUT) * TIMEOUT_USEC = Option.from_option(ssh_options_e.SSH_OPTIONS_TIMEOUT_USEC) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_KNOWNHOSTS)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_KNOWNHOSTS)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_KNOWNHOSTS, __pyx_t_1) < 0) __PYX_ERR(0, 52, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_KNOWNHOSTS, __pyx_t_1) < 0) __PYX_ERR(0, 51, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":53 + /* "ssh/options.pyx":52 * ADD_IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_ADD_IDENTITY) * KNOWNHOSTS = Option.from_option(ssh_options_e.SSH_OPTIONS_KNOWNHOSTS) * TIMEOUT = Option.from_option(ssh_options_e.SSH_OPTIONS_TIMEOUT) # <<<<<<<<<<<<<< * TIMEOUT_USEC = Option.from_option(ssh_options_e.SSH_OPTIONS_TIMEOUT_USEC) * SSH1 = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH1) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_TIMEOUT)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_TIMEOUT)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIMEOUT, __pyx_t_1) < 0) __PYX_ERR(0, 53, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIMEOUT, __pyx_t_1) < 0) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":54 + /* "ssh/options.pyx":53 * KNOWNHOSTS = Option.from_option(ssh_options_e.SSH_OPTIONS_KNOWNHOSTS) * TIMEOUT = Option.from_option(ssh_options_e.SSH_OPTIONS_TIMEOUT) * TIMEOUT_USEC = Option.from_option(ssh_options_e.SSH_OPTIONS_TIMEOUT_USEC) # <<<<<<<<<<<<<< * SSH1 = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH1) * SSH2 = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH2) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_TIMEOUT_USEC)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_TIMEOUT_USEC)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIMEOUT_USEC, __pyx_t_1) < 0) __PYX_ERR(0, 54, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_TIMEOUT_USEC, __pyx_t_1) < 0) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":55 + /* "ssh/options.pyx":54 * TIMEOUT = Option.from_option(ssh_options_e.SSH_OPTIONS_TIMEOUT) * TIMEOUT_USEC = Option.from_option(ssh_options_e.SSH_OPTIONS_TIMEOUT_USEC) * SSH1 = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH1) # <<<<<<<<<<<<<< * SSH2 = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH2) * LOG_VERBOSITY = Option.from_option(ssh_options_e.SSH_OPTIONS_LOG_VERBOSITY) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_SSH1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_SSH1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_SSH1, __pyx_t_1) < 0) __PYX_ERR(0, 55, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_SSH1, __pyx_t_1) < 0) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":56 + /* "ssh/options.pyx":55 * TIMEOUT_USEC = Option.from_option(ssh_options_e.SSH_OPTIONS_TIMEOUT_USEC) * SSH1 = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH1) * SSH2 = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH2) # <<<<<<<<<<<<<< * LOG_VERBOSITY = Option.from_option(ssh_options_e.SSH_OPTIONS_LOG_VERBOSITY) * LOG_VERBOSITY_STR = Option.from_option( */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_SSH2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_SSH2)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_SSH2, __pyx_t_1) < 0) __PYX_ERR(0, 56, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_SSH2, __pyx_t_1) < 0) __PYX_ERR(0, 55, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":57 + /* "ssh/options.pyx":56 * SSH1 = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH1) * SSH2 = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH2) * LOG_VERBOSITY = Option.from_option(ssh_options_e.SSH_OPTIONS_LOG_VERBOSITY) # <<<<<<<<<<<<<< * LOG_VERBOSITY_STR = Option.from_option( * ssh_options_e.SSH_OPTIONS_LOG_VERBOSITY_STR) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_LOG_VERBOSITY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_LOG_VERBOSITY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LOG_VERBOSITY, __pyx_t_1) < 0) __PYX_ERR(0, 57, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LOG_VERBOSITY, __pyx_t_1) < 0) __PYX_ERR(0, 56, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":58 + /* "ssh/options.pyx":57 * SSH2 = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH2) * LOG_VERBOSITY = Option.from_option(ssh_options_e.SSH_OPTIONS_LOG_VERBOSITY) * LOG_VERBOSITY_STR = Option.from_option( # <<<<<<<<<<<<<< * ssh_options_e.SSH_OPTIONS_LOG_VERBOSITY_STR) * CIPHERS_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_CIPHERS_C_S) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_LOG_VERBOSITY_STR)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_LOG_VERBOSITY_STR)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_LOG_VERBOSITY_STR, __pyx_t_1) < 0) __PYX_ERR(0, 58, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_LOG_VERBOSITY_STR, __pyx_t_1) < 0) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":60 + /* "ssh/options.pyx":59 * LOG_VERBOSITY_STR = Option.from_option( * ssh_options_e.SSH_OPTIONS_LOG_VERBOSITY_STR) * CIPHERS_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_CIPHERS_C_S) # <<<<<<<<<<<<<< * CIPHERS_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_CIPHERS_S_C) * COMPRESSION_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION_C_S) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_CIPHERS_C_S)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_CIPHERS_C_S)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_CIPHERS_C_S, __pyx_t_1) < 0) __PYX_ERR(0, 60, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_CIPHERS_C_S, __pyx_t_1) < 0) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":61 + /* "ssh/options.pyx":60 * ssh_options_e.SSH_OPTIONS_LOG_VERBOSITY_STR) * CIPHERS_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_CIPHERS_C_S) * CIPHERS_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_CIPHERS_S_C) # <<<<<<<<<<<<<< * COMPRESSION_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION_C_S) * COMPRESSION_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION_S_C) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_CIPHERS_S_C)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_CIPHERS_S_C)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_CIPHERS_S_C, __pyx_t_1) < 0) __PYX_ERR(0, 61, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_CIPHERS_S_C, __pyx_t_1) < 0) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":62 + /* "ssh/options.pyx":61 * CIPHERS_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_CIPHERS_C_S) * CIPHERS_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_CIPHERS_S_C) * COMPRESSION_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION_C_S) # <<<<<<<<<<<<<< * COMPRESSION_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION_S_C) * PROXYCOMMAND = Option.from_option(ssh_options_e.SSH_OPTIONS_PROXYCOMMAND) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_COMPRESSION_C_S)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_COMPRESSION_C_S)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_COMPRESSION_C_S, __pyx_t_1) < 0) __PYX_ERR(0, 62, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_COMPRESSION_C_S, __pyx_t_1) < 0) __PYX_ERR(0, 61, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":63 + /* "ssh/options.pyx":62 * CIPHERS_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_CIPHERS_S_C) * COMPRESSION_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION_C_S) * COMPRESSION_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION_S_C) # <<<<<<<<<<<<<< * PROXYCOMMAND = Option.from_option(ssh_options_e.SSH_OPTIONS_PROXYCOMMAND) * BINDADDR = Option.from_option(ssh_options_e.SSH_OPTIONS_BINDADDR) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_COMPRESSION_S_C)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_COMPRESSION_S_C)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_COMPRESSION_S_C, __pyx_t_1) < 0) __PYX_ERR(0, 63, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_COMPRESSION_S_C, __pyx_t_1) < 0) __PYX_ERR(0, 62, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":64 + /* "ssh/options.pyx":63 * COMPRESSION_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION_C_S) * COMPRESSION_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION_S_C) * PROXYCOMMAND = Option.from_option(ssh_options_e.SSH_OPTIONS_PROXYCOMMAND) # <<<<<<<<<<<<<< * BINDADDR = Option.from_option(ssh_options_e.SSH_OPTIONS_BINDADDR) * STRICTHOSTKEYCHECK = Option.from_option( */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_PROXYCOMMAND)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_PROXYCOMMAND)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_PROXYCOMMAND, __pyx_t_1) < 0) __PYX_ERR(0, 64, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_PROXYCOMMAND, __pyx_t_1) < 0) __PYX_ERR(0, 63, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":65 + /* "ssh/options.pyx":64 * COMPRESSION_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION_S_C) * PROXYCOMMAND = Option.from_option(ssh_options_e.SSH_OPTIONS_PROXYCOMMAND) * BINDADDR = Option.from_option(ssh_options_e.SSH_OPTIONS_BINDADDR) # <<<<<<<<<<<<<< * STRICTHOSTKEYCHECK = Option.from_option( * ssh_options_e.SSH_OPTIONS_STRICTHOSTKEYCHECK) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_BINDADDR)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_BINDADDR)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_BINDADDR, __pyx_t_1) < 0) __PYX_ERR(0, 65, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_BINDADDR, __pyx_t_1) < 0) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":66 + /* "ssh/options.pyx":65 * PROXYCOMMAND = Option.from_option(ssh_options_e.SSH_OPTIONS_PROXYCOMMAND) * BINDADDR = Option.from_option(ssh_options_e.SSH_OPTIONS_BINDADDR) * STRICTHOSTKEYCHECK = Option.from_option( # <<<<<<<<<<<<<< * ssh_options_e.SSH_OPTIONS_STRICTHOSTKEYCHECK) * COMPRESSION = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_STRICTHOSTKEYCHECK)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_STRICTHOSTKEYCHECK)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_STRICTHOSTKEYCHECK, __pyx_t_1) < 0) __PYX_ERR(0, 66, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_STRICTHOSTKEYCHECK, __pyx_t_1) < 0) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":68 + /* "ssh/options.pyx":67 * STRICTHOSTKEYCHECK = Option.from_option( * ssh_options_e.SSH_OPTIONS_STRICTHOSTKEYCHECK) * COMPRESSION = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION) # <<<<<<<<<<<<<< * COMPRESSION_LEVEL = Option.from_option( * ssh_options_e.SSH_OPTIONS_COMPRESSION_LEVEL) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_COMPRESSION)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_COMPRESSION)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_COMPRESSION, __pyx_t_1) < 0) __PYX_ERR(0, 68, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_COMPRESSION, __pyx_t_1) < 0) __PYX_ERR(0, 67, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":69 + /* "ssh/options.pyx":68 * ssh_options_e.SSH_OPTIONS_STRICTHOSTKEYCHECK) * COMPRESSION = Option.from_option(ssh_options_e.SSH_OPTIONS_COMPRESSION) * COMPRESSION_LEVEL = Option.from_option( # <<<<<<<<<<<<<< * ssh_options_e.SSH_OPTIONS_COMPRESSION_LEVEL) * KEY_EXCHANGE = Option.from_option(ssh_options_e.SSH_OPTIONS_KEY_EXCHANGE) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_COMPRESSION_LEVEL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_COMPRESSION_LEVEL)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_COMPRESSION_LEVEL, __pyx_t_1) < 0) __PYX_ERR(0, 69, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_COMPRESSION_LEVEL, __pyx_t_1) < 0) __PYX_ERR(0, 68, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":71 + /* "ssh/options.pyx":70 * COMPRESSION_LEVEL = Option.from_option( * ssh_options_e.SSH_OPTIONS_COMPRESSION_LEVEL) * KEY_EXCHANGE = Option.from_option(ssh_options_e.SSH_OPTIONS_KEY_EXCHANGE) # <<<<<<<<<<<<<< * HOSTKEYS = Option.from_option(ssh_options_e.SSH_OPTIONS_HOSTKEYS) * GSSAPI_SERVER_IDENTITY = Option.from_option( */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_KEY_EXCHANGE)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_KEY_EXCHANGE)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_KEY_EXCHANGE, __pyx_t_1) < 0) __PYX_ERR(0, 71, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_KEY_EXCHANGE, __pyx_t_1) < 0) __PYX_ERR(0, 70, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":72 + /* "ssh/options.pyx":71 * ssh_options_e.SSH_OPTIONS_COMPRESSION_LEVEL) * KEY_EXCHANGE = Option.from_option(ssh_options_e.SSH_OPTIONS_KEY_EXCHANGE) * HOSTKEYS = Option.from_option(ssh_options_e.SSH_OPTIONS_HOSTKEYS) # <<<<<<<<<<<<<< * GSSAPI_SERVER_IDENTITY = Option.from_option( * ssh_options_e.SSH_OPTIONS_GSSAPI_SERVER_IDENTITY) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_HOSTKEYS)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_HOSTKEYS)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_HOSTKEYS, __pyx_t_1) < 0) __PYX_ERR(0, 72, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_HOSTKEYS, __pyx_t_1) < 0) __PYX_ERR(0, 71, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":73 + /* "ssh/options.pyx":72 * KEY_EXCHANGE = Option.from_option(ssh_options_e.SSH_OPTIONS_KEY_EXCHANGE) * HOSTKEYS = Option.from_option(ssh_options_e.SSH_OPTIONS_HOSTKEYS) * GSSAPI_SERVER_IDENTITY = Option.from_option( # <<<<<<<<<<<<<< * ssh_options_e.SSH_OPTIONS_GSSAPI_SERVER_IDENTITY) * GSSAPI_CLIENT_IDENTITY = Option.from_option( */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_GSSAPI_SERVER_IDENTITY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_GSSAPI_SERVER_IDENTITY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_GSSAPI_SERVER_IDENTITY, __pyx_t_1) < 0) __PYX_ERR(0, 73, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_GSSAPI_SERVER_IDENTITY, __pyx_t_1) < 0) __PYX_ERR(0, 72, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":75 + /* "ssh/options.pyx":74 * GSSAPI_SERVER_IDENTITY = Option.from_option( * ssh_options_e.SSH_OPTIONS_GSSAPI_SERVER_IDENTITY) * GSSAPI_CLIENT_IDENTITY = Option.from_option( # <<<<<<<<<<<<<< * ssh_options_e.SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY) * GSSAPI_DELEGATE_CREDENTIALS = Option.from_option( */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_GSSAPI_CLIENT_IDENTITY, __pyx_t_1) < 0) __PYX_ERR(0, 75, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_GSSAPI_CLIENT_IDENTITY, __pyx_t_1) < 0) __PYX_ERR(0, 74, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":77 + /* "ssh/options.pyx":76 * GSSAPI_CLIENT_IDENTITY = Option.from_option( * ssh_options_e.SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY) * GSSAPI_DELEGATE_CREDENTIALS = Option.from_option( # <<<<<<<<<<<<<< * ssh_options_e.SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS) * HMAC_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_HMAC_C_S) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_GSSAPI_DELEGATE_CREDENTIALS, __pyx_t_1) < 0) __PYX_ERR(0, 77, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_GSSAPI_DELEGATE_CREDENTIALS, __pyx_t_1) < 0) __PYX_ERR(0, 76, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":79 + /* "ssh/options.pyx":78 * GSSAPI_DELEGATE_CREDENTIALS = Option.from_option( * ssh_options_e.SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS) * HMAC_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_HMAC_C_S) # <<<<<<<<<<<<<< * HMAC_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_HMAC_S_C) * PASSWORD_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_PASSWORD_AUTH) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_HMAC_C_S)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_HMAC_C_S)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_HMAC_C_S, __pyx_t_1) < 0) __PYX_ERR(0, 79, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_HMAC_C_S, __pyx_t_1) < 0) __PYX_ERR(0, 78, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":80 + /* "ssh/options.pyx":79 * ssh_options_e.SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS) * HMAC_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_HMAC_C_S) * HMAC_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_HMAC_S_C) # <<<<<<<<<<<<<< * PASSWORD_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_PASSWORD_AUTH) * PUBKEY_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_PUBKEY_AUTH) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_HMAC_S_C)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_HMAC_S_C)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_HMAC_S_C, __pyx_t_1) < 0) __PYX_ERR(0, 80, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_HMAC_S_C, __pyx_t_1) < 0) __PYX_ERR(0, 79, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":81 + /* "ssh/options.pyx":80 * HMAC_C_S = Option.from_option(ssh_options_e.SSH_OPTIONS_HMAC_C_S) * HMAC_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_HMAC_S_C) * PASSWORD_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_PASSWORD_AUTH) # <<<<<<<<<<<<<< * PUBKEY_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_PUBKEY_AUTH) * KBDINT_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_KBDINT_AUTH) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_PASSWORD_AUTH)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_PASSWORD_AUTH)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_PASSWORD_AUTH, __pyx_t_1) < 0) __PYX_ERR(0, 81, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_PASSWORD_AUTH, __pyx_t_1) < 0) __PYX_ERR(0, 80, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":82 + /* "ssh/options.pyx":81 * HMAC_S_C = Option.from_option(ssh_options_e.SSH_OPTIONS_HMAC_S_C) * PASSWORD_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_PASSWORD_AUTH) * PUBKEY_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_PUBKEY_AUTH) # <<<<<<<<<<<<<< * KBDINT_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_KBDINT_AUTH) * GSSAPI_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_GSSAPI_AUTH) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_PUBKEY_AUTH)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_PUBKEY_AUTH)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_PUBKEY_AUTH, __pyx_t_1) < 0) __PYX_ERR(0, 82, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_PUBKEY_AUTH, __pyx_t_1) < 0) __PYX_ERR(0, 81, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":83 + /* "ssh/options.pyx":82 * PASSWORD_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_PASSWORD_AUTH) * PUBKEY_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_PUBKEY_AUTH) * KBDINT_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_KBDINT_AUTH) # <<<<<<<<<<<<<< * GSSAPI_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_GSSAPI_AUTH) * GLOBAL_KNOWNHOSTS = Option.from_option( */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_KBDINT_AUTH)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_KBDINT_AUTH)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_KBDINT_AUTH, __pyx_t_1) < 0) __PYX_ERR(0, 83, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_KBDINT_AUTH, __pyx_t_1) < 0) __PYX_ERR(0, 82, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":84 + /* "ssh/options.pyx":83 * PUBKEY_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_PUBKEY_AUTH) * KBDINT_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_KBDINT_AUTH) * GSSAPI_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_GSSAPI_AUTH) # <<<<<<<<<<<<<< * GLOBAL_KNOWNHOSTS = Option.from_option( * ssh_options_e.SSH_OPTIONS_GLOBAL_KNOWNHOSTS) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_GSSAPI_AUTH)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_GSSAPI_AUTH)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_GSSAPI_AUTH, __pyx_t_1) < 0) __PYX_ERR(0, 84, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_GSSAPI_AUTH, __pyx_t_1) < 0) __PYX_ERR(0, 83, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":85 + /* "ssh/options.pyx":84 * KBDINT_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_KBDINT_AUTH) * GSSAPI_AUTH = Option.from_option(ssh_options_e.SSH_OPTIONS_GSSAPI_AUTH) * GLOBAL_KNOWNHOSTS = Option.from_option( # <<<<<<<<<<<<<< * ssh_options_e.SSH_OPTIONS_GLOBAL_KNOWNHOSTS) * NODELAY = Option.from_option(ssh_options_e.SSH_OPTIONS_NODELAY) */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_GLOBAL_KNOWNHOSTS)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_GLOBAL_KNOWNHOSTS)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_GLOBAL_KNOWNHOSTS, __pyx_t_1) < 0) __PYX_ERR(0, 85, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_GLOBAL_KNOWNHOSTS, __pyx_t_1) < 0) __PYX_ERR(0, 84, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - /* "ssh/options.pyx":87 + /* "ssh/options.pyx":86 * GLOBAL_KNOWNHOSTS = Option.from_option( * ssh_options_e.SSH_OPTIONS_GLOBAL_KNOWNHOSTS) * NODELAY = Option.from_option(ssh_options_e.SSH_OPTIONS_NODELAY) # <<<<<<<<<<<<<< */ - __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_NODELAY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error) + __pyx_t_1 = ((PyObject *)__pyx_f_3ssh_7options_6Option_from_option(SSH_OPTIONS_NODELAY)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_NODELAY, __pyx_t_1) < 0) __PYX_ERR(0, 87, __pyx_L1_error) + if (PyDict_SetItem(__pyx_d, __pyx_n_s_NODELAY, __pyx_t_1) < 0) __PYX_ERR(0, 86, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; /* "(tree fragment)":1 diff --git a/ssh/options.pyx b/ssh/options.pyx index bff6538..375a5fe 100644 --- a/ssh/options.pyx +++ b/ssh/options.pyx @@ -45,7 +45,6 @@ USER = Option.from_option(ssh_options_e.SSH_OPTIONS_USER) PORT = Option.from_option(ssh_options_e.SSH_OPTIONS_PORT) PORT_STR = Option.from_option(ssh_options_e.SSH_OPTIONS_PORT_STR) FD = Option.from_option(ssh_options_e.SSH_OPTIONS_FD) -USER = Option.from_option(ssh_options_e.SSH_OPTIONS_USER) SSH_DIR = Option.from_option(ssh_options_e.SSH_OPTIONS_SSH_DIR) IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_IDENTITY) ADD_IDENTITY = Option.from_option(ssh_options_e.SSH_OPTIONS_ADD_IDENTITY) diff --git a/tests/test_channel.py b/tests/test_channel.py index 4d984f0..ff2b440 100644 --- a/tests/test_channel.py +++ b/tests/test_channel.py @@ -156,3 +156,30 @@ def test_pty(self): self.assertTrue(size > 0) lines = [s.decode('utf-8') for s in data.splitlines()] self.assertListEqual(expected, lines) + + def test_write_stdin(self): + self._auth() + _in = u'writing to stdin' + chan = self.session.channel_new() + chan.open_session() + chan.request_exec('cat') + chan.write(_in + '\n') + self.assertEqual(chan.send_eof(), 0) + size, data = chan.read() + self.assertTrue(size > 0) + lines = [line.decode('utf-8') for line in data.splitlines()] + self.assertListEqual([_in], lines) + chan.close() + chan.read() + self.assertTrue(chan.is_eof()) + + def test_write_stderr(self): + self._auth() + chan = self.session.channel_new() + chan.open_session() + chan.request_exec('echo something') + _in = u'stderr' + rc, bytes_written = chan.write_stderr(_in + '\n') + self.assertEqual(rc, 7) + self.assertEqual(bytes_written, 7) + self.assertEqual(chan.close(), 0)