Exemple #1
0
@rtype  libssh2.Channel";

static PyObject *
PYLIBSSH2_Session_open_session(PYLIBSSH2_SESSION *self, PyObject *args)
{
    int dealloc = 1;
    LIBSSH2_CHANNEL *channel;

    if (!PyArg_ParseTuple(args, "|i:open_session", &dealloc)) {
        return NULL;
    }

    channel = libssh2_channel_open_session(self->session);
    
    if (channel== NULL){
      if (libssh2_session_last_error(self->session,NULL,NULL,0) ==
	  LIBSSH2_ERROR_EAGAIN){
	return Py_BuildValue("");
	}
      else{
	PyErr_SetString(PYLIBSSH2_Error, "Failed to open channel");
	return NULL;
      }
    }
    else {
      return (PyObject *)PYLIBSSH2_Channel_New(channel, dealloc);
    }
}
Exemple #2
0
x11_req() -- requests an X11 Forwarding channel\n\
");

static PyObject *
PYLIBSSH2_Channel(PyObject *self, PyObject *args)
{
    PYLIBSSH2_SESSION *session;
    LIBSSH2_CHANNEL *channel;
    int dealloc = 1;

    if (!PyArg_ParseTuple(args, "O|i:Channel", &session, &dealloc)) {
        return NULL;
    }

    channel = libssh2_channel_open_session(session->session);

    if (channel== NULL){
      if (libssh2_session_last_error(session->session,NULL,NULL,0) ==
	  LIBSSH2_ERROR_EAGAIN){
	return Py_BuildValue("");
	}
      else{
	PyErr_SetString(PYLIBSSH2_Error, "Failed to open channel");
	return NULL;
      }
    }
    else {
      return (PyObject *)PYLIBSSH2_Channel_New(channel, dealloc);
    }
}