Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cellframe/python-cellframe
1 result
Show changes
Commits on Source (4)
......@@ -9,14 +9,12 @@ void dap_chain_node_client_deinit_py(void){
PyObject *dap_chain_client_connect_py(PyObject *self, PyObject *args){
PyObject *obj_node_info;
PyObject *obj_client_stage;
const char *active_channels;
if (!PyArg_ParseTuple(args, "O|O|s", &obj_node_info, &obj_client_stage, &active_channels))
if (!PyArg_ParseTuple(args, "O|s", &obj_node_info, &active_channels))
return NULL;
PyObject *obj_node_client = _PyObject_New(&DapChainNodeClientObject_DapChainNodeClientObjectType);
((PyDapChainNodeClientObject*)obj_node_client)->node_client =dap_chain_client_connect(
((PyDapChainNodeInfoObject*)obj_node_info)->node_info,
((PyDapClientStageObject*)obj_client_stage)->stage, active_channels);
((PyDapChainNodeInfoObject*)obj_node_info)->node_info, active_channels);
return Py_BuildValue("O", obj_node_client);
}
PyObject *dap_chain_node_client_connect_py(PyObject *self, PyObject *args){
......
......@@ -4,6 +4,7 @@
#include "http_status_code.h"
#include "Python.h"
#undef LOG_TAG
#define LOG_TAG "wrapping_http_status_code"
#ifdef __cplusplus
......@@ -166,6 +167,8 @@ static PyTypeObject HTTPCode_HTTPCodeType = {
PyType_GenericNew, /* tp_new */
};
#undef LOG_TAG
#ifdef __cplusplus
}
#endif
......@@ -25,6 +25,8 @@ PyObject *_w_simple_proc_find(const char *url){
void wrapping_dap_http_simple_callback(dap_http_simple_t *sh, void *obj){
log_it(L_DEBUG, "Handling C module request");
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
PyObject *obj_func = _w_simple_proc_find(sh->http_client->url_path);
PyDapHttpSimpleObject *obj_http_simple = PyObject_NEW(PyDapHttpSimpleObject, &DapHTTPSimple_DapHTTPSimpleType);
PyObject *obj_http_status_code = _PyObject_New(&HTTPCode_HTTPCodeType);
......@@ -34,6 +36,7 @@ void wrapping_dap_http_simple_callback(dap_http_simple_t *sh, void *obj){
((PyHttpStatusCodeObject*)obj_http_status_code)->http_status = *ret;
PyObject_Dir((PyObject*)obj_http_status_code);
PyObject *obj_argv = Py_BuildValue("OO", obj_http_simple, obj_http_status_code);
PyErr_Print();
PyObject *result = PyObject_CallObject(obj_func, obj_argv);
if (!result){
log_it(L_DEBUG, "Function can't called");
......@@ -41,9 +44,10 @@ void wrapping_dap_http_simple_callback(dap_http_simple_t *sh, void *obj){
*ret = Http_Status_InternalServerError;
}
*ret = ((PyHttpStatusCodeObject*)obj_http_status_code)->http_status;
// Py_XDECREF(obj_argv);
// Py_XDECREF(obj_http_status_code);
// Py_XDECREF(obj_http_simple);
Py_XDECREF(obj_argv);
Py_XDECREF(obj_http_status_code);
Py_XDECREF(obj_http_simple);
PyGILState_Release(gstate);
}
PyObject *dap_http_simple_add_proc_py(PyObject *self, PyObject *args){
......
......@@ -8,6 +8,7 @@
#include "dap_chain_plugins.h"
#undef LOG_TAG
#define LOG_TAG "dap_chain_plugins"
PyObject *s_sys_path = NULL;
......@@ -27,6 +28,7 @@ int dap_chain_plugins_init(dap_config_t *a_config){
}
PyImport_AppendInittab("API_CellFrame", PyInit_libCellFrame);
Py_Initialize();
PyEval_InitThreads();
PyObject *l_sys_module = PyImport_ImportModule("sys");
s_sys_path = PyObject_GetAttrString(l_sys_module, "path");
//Get list files
......@@ -47,6 +49,7 @@ int dap_chain_plugins_init(dap_config_t *a_config){
}
dap_chain_plugins_loading();
dap_chain_plugins_command_create();
PyThreadState *l_thread_state = PyEval_SaveThread();
}else{
log_it(L_NOTICE, "Permission to initialize python plugins has not been obtained.");
return -2;
......
......@@ -30,14 +30,19 @@ bool dap_chain_plugins_list_check_load_plugins(dap_chain_plugins_list_char_t *a_
int lenght;
LL_COUNT(s_dap_chain_plugins_module_list, l_element_from_list_module, lenght);
if (lenght == 0)
if (lenght == 0){
DAP_FREE(l_element_lnk);
return false;
}
LL_FOREACH(a_list, l_value_from_list){
l_element_lnk->name = l_value_from_list->value;
LL_SEARCH(s_dap_chain_plugins_module_list, l_element_from_list_module, l_element_lnk, dap_chain_plugins_list_cmp);
if (!l_element_from_list_module)
if (!l_element_from_list_module){
DAP_FREE(l_element_lnk);
return false;
}
}
DAP_FREE(l_element_lnk);
return true;
}
......
......@@ -43,7 +43,7 @@ dap_chain_plugins_list_manifest_t *dap_chain_plugins_manifest_new(const char *a_
static dap_chain_plugins_list_char_t* JSON_array_to_dap_list_char(json_object *a_j_obj){
dap_chain_plugins_list_char_t *l_list = NULL;
dap_chain_plugins_list_char_t *l_element = NULL;
for (size_t i = 0; i < json_object_array_length(a_j_obj); i++){
for (size_t i = 0; i < (size_t)json_object_array_length(a_j_obj); i++){
l_element = (dap_chain_plugins_list_char_t*)DAP_NEW(dap_chain_plugins_list_char_t);
l_element->value = dap_strdup(json_object_get_string(json_object_array_get_idx(a_j_obj, i)));
LL_APPEND(l_list, l_element);
......@@ -75,20 +75,35 @@ dap_chain_plugins_list_manifest_t* dap_chain_plugins_add_manifest_from_file(cons
fclose(file);
//Parse JSON
json_object *j_obj = json_tokener_parse(json);
json_object *j_name = json_object_object_get(j_obj, "name");
json_object *j_version = json_object_object_get(j_obj, "version");
json_object *j_dependencys = json_object_object_get(j_obj, "dependencys");
json_object *j_author = json_object_object_get(j_obj, "author");
json_object *j_description = json_object_object_get(j_obj, "description");
json_object *j_name;
json_object *j_version;
json_object *j_dependencys;
json_object *j_author;
json_object *j_description;
if (!json_object_object_get_ex(j_obj, "name", &j_name))
return NULL;
if (!json_object_object_get_ex(j_obj, "version", &j_version))
return NULL;
if (!json_object_object_get_ex(j_obj, "dependencys", &j_dependencys))
return NULL;
if (!json_object_object_get_ex(j_obj, "author", &j_author))
return NULL;
if (!json_object_object_get_ex(j_obj, "description", &j_description))
return NULL;
const char *name, *version, *author, *description;
name = json_object_get_string(j_name);
version = json_object_get_string(j_version);
author = json_object_get_string(j_author);
description = json_object_get_string(j_description);
dap_chain_plugins_list_char_t *dep = JSON_array_to_dap_list_char(j_dependencys);
DAP_FREE(json);
dap_chain_plugins_list_char_t *tmp = NULL;
dap_chain_plugins_list_manifest_t *manifest = dap_chain_plugins_manifest_new(name, version, dep, author, description);
json_object_put(j_dependencys);
json_object_put(j_description);
json_object_put(j_author);
json_object_put(j_version);
json_object_put(j_name);
json_object_put(j_obj);
DAP_FREE(json);
return manifest;
}
......