From 8598b22e101201de4d06ea48f2b500f81f2b30d5 Mon Sep 17 00:00:00 2001 From: Jiri Moskovcak Date: Tue, 14 Dec 2010 13:56:07 +0100 Subject: a stub for report-python --- src/report-python/reportmodule.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/report-python/reportmodule.c (limited to 'src/report-python/reportmodule.c') diff --git a/src/report-python/reportmodule.c b/src/report-python/reportmodule.c new file mode 100644 index 00000000..b73f88f5 --- /dev/null +++ b/src/report-python/reportmodule.c @@ -0,0 +1,34 @@ +#include +#include "py_crash_dump.h" + +PyObject *ReportError; + +#ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ +#define PyMODINIT_FUNC void +#endif +PyMODINIT_FUNC +init_pyreport(void) +{ + PyObject* m; + + if (PyType_Ready(&p_crash_data_type) < 0) + { + printf("PyType_Ready(&p_crash_data_type) < 0"); + return; + } + + m = Py_InitModule3("_pyreport", module_methods, "Python wrapper around crash_data_t"); + if (m == NULL) + { + printf("m == NULL"); + return; + } + + /* init the exception object */ + ReportError = PyErr_NewException("_pyreport.error", NULL, NULL); + Py_INCREF(ReportError); + PyModule_AddObject(m, "error", ReportError); + + Py_INCREF(&p_crash_data_type); + PyModule_AddObject(m, "crash_data", (PyObject *)&p_crash_data_type); +} -- cgit From b1f4a3256004e8f12c15511d2b77074a3002b9f2 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 14 Dec 2010 17:17:07 +0100 Subject: jury-rig compile for python2.6; small style fixes Signed-off-by: Denys Vlasenko --- src/report-python/reportmodule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/report-python/reportmodule.c') diff --git a/src/report-python/reportmodule.c b/src/report-python/reportmodule.c index b73f88f5..7955ab83 100644 --- a/src/report-python/reportmodule.c +++ b/src/report-python/reportmodule.c @@ -20,7 +20,7 @@ init_pyreport(void) m = Py_InitModule3("_pyreport", module_methods, "Python wrapper around crash_data_t"); if (m == NULL) { - printf("m == NULL"); + printf("m == NULL\n"); return; } -- cgit From 2fa1f3ac7f960e4bf306e53c1aac06fe0e31a4ba Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 15 Dec 2010 06:15:27 +0100 Subject: simplify python wrapper code Signed-off-by: Denys Vlasenko --- src/report-python/reportmodule.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/report-python/reportmodule.c') diff --git a/src/report-python/reportmodule.c b/src/report-python/reportmodule.c index 7955ab83..6d44d493 100644 --- a/src/report-python/reportmodule.c +++ b/src/report-python/reportmodule.c @@ -1,5 +1,23 @@ +/* + Copyright (C) 2010 Abrt team. + Copyright (C) 2010 RedHat inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ #include -#include "py_crash_dump.h" +#include "common.h" PyObject *ReportError; @@ -13,11 +31,11 @@ init_pyreport(void) if (PyType_Ready(&p_crash_data_type) < 0) { - printf("PyType_Ready(&p_crash_data_type) < 0"); + printf("PyType_Ready(&p_crash_data_type) < 0\n"); return; } - m = Py_InitModule3("_pyreport", module_methods, "Python wrapper around crash_data_t"); + m = Py_InitModule3("_pyreport", /*module_methods:*/ NULL, "Python wrapper for libreport"); if (m == NULL) { printf("m == NULL\n"); -- cgit From 544804d5e19cd8890c069273bd93801689e6f8e7 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 15 Dec 2010 06:18:07 +0100 Subject: python wrappers: add dump_dir wrapper Signed-off-by: Denys Vlasenko --- src/report-python/reportmodule.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/report-python/reportmodule.c') diff --git a/src/report-python/reportmodule.c b/src/report-python/reportmodule.c index 6d44d493..f98ba75e 100644 --- a/src/report-python/reportmodule.c +++ b/src/report-python/reportmodule.c @@ -21,6 +21,13 @@ PyObject *ReportError; +//static PyMethodDef module_methods[] = { +// { "dd_opendir" , p_dd_opendir, METH_VARARGS, NULL }; +// { "dd_create" , p_dd_create, METH_VARARGS, NULL }; +// { "delete_crash_dump_dir", p_delete_crash_dump_dir, METH_VARARGS, NULL }, +// { NULL } +//}; + #ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ #define PyMODINIT_FUNC void #endif @@ -34,6 +41,11 @@ init_pyreport(void) printf("PyType_Ready(&p_crash_data_type) < 0\n"); return; } + if (PyType_Ready(&p_dump_dir_type) < 0) + { + printf("PyType_Ready(&p_dump_dir_type) < 0\n"); + return; + } m = Py_InitModule3("_pyreport", /*module_methods:*/ NULL, "Python wrapper for libreport"); if (m == NULL) @@ -49,4 +61,7 @@ init_pyreport(void) Py_INCREF(&p_crash_data_type); PyModule_AddObject(m, "crash_data", (PyObject *)&p_crash_data_type); + + Py_INCREF(&p_dump_dir_type); + PyModule_AddObject(m, "dump_dir", (PyObject *)&p_dump_dir_type); } -- cgit From 6da0fdade325c2ce0f371e661801e6beb1e70cdb Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 15 Dec 2010 18:33:43 +0100 Subject: python wrappers: make crash_data.create_crash_dump_dir() work Signed-off-by: Denys Vlasenko --- src/report-python/reportmodule.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/report-python/reportmodule.c') diff --git a/src/report-python/reportmodule.c b/src/report-python/reportmodule.c index f98ba75e..5fa31ca2 100644 --- a/src/report-python/reportmodule.c +++ b/src/report-python/reportmodule.c @@ -21,12 +21,12 @@ PyObject *ReportError; -//static PyMethodDef module_methods[] = { -// { "dd_opendir" , p_dd_opendir, METH_VARARGS, NULL }; -// { "dd_create" , p_dd_create, METH_VARARGS, NULL }; +static PyMethodDef module_methods[] = { + { "dd_opendir" , p_dd_opendir, METH_VARARGS, NULL }, + { "dd_create" , p_dd_create, METH_VARARGS, NULL }, // { "delete_crash_dump_dir", p_delete_crash_dump_dir, METH_VARARGS, NULL }, -// { NULL } -//}; + { NULL } +}; #ifndef PyMODINIT_FUNC /* declarations for DLL import/export */ #define PyMODINIT_FUNC void @@ -47,8 +47,9 @@ init_pyreport(void) return; } - m = Py_InitModule3("_pyreport", /*module_methods:*/ NULL, "Python wrapper for libreport"); - if (m == NULL) + m = Py_InitModule("_pyreport", module_methods); + //m = Py_InitModule3("_pyreport", module_methods, "Python wrapper for libreport"); + if (!m) { printf("m == NULL\n"); return; -- cgit From 6a2b728d7525214402eff838bb37be175ddce6c3 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 15 Dec 2010 18:44:55 +0100 Subject: Rename foo_crash_dump_dir -> foo_dump_dir To be exact, these three functions are renamed: load_crash_data_from_crash_dump_dir create_crash_dump_dir delete_crash_dump_dir Rationale: data structure is called "struct dump_dir", not "struct crash_dump_dir" Signed-off-by: Denys Vlasenko --- src/report-python/reportmodule.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/report-python/reportmodule.c') diff --git a/src/report-python/reportmodule.c b/src/report-python/reportmodule.c index 5fa31ca2..4d38eeab 100644 --- a/src/report-python/reportmodule.c +++ b/src/report-python/reportmodule.c @@ -22,9 +22,9 @@ PyObject *ReportError; static PyMethodDef module_methods[] = { - { "dd_opendir" , p_dd_opendir, METH_VARARGS, NULL }, - { "dd_create" , p_dd_create, METH_VARARGS, NULL }, -// { "delete_crash_dump_dir", p_delete_crash_dump_dir, METH_VARARGS, NULL }, + { "dd_opendir" , p_dd_opendir, METH_VARARGS, NULL }, + { "dd_create" , p_dd_create, METH_VARARGS, NULL }, +// { "delete_dump_dir", p_delete_dump_dir, METH_VARARGS, NULL }, { NULL } }; -- cgit From 93d5d8a317ec9294bbd6dcc6bd8baec0c2b63b1b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 16 Dec 2010 13:15:37 +0100 Subject: report-python/run_event.c: python wrappers for run_event.h API Signed-off-by: Denys Vlasenko --- src/report-python/reportmodule.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/report-python/reportmodule.c') diff --git a/src/report-python/reportmodule.c b/src/report-python/reportmodule.c index 4d38eeab..db9f52d9 100644 --- a/src/report-python/reportmodule.c +++ b/src/report-python/reportmodule.c @@ -34,8 +34,6 @@ static PyMethodDef module_methods[] = { PyMODINIT_FUNC init_pyreport(void) { - PyObject* m; - if (PyType_Ready(&p_crash_data_type) < 0) { printf("PyType_Ready(&p_crash_data_type) < 0\n"); @@ -46,8 +44,13 @@ init_pyreport(void) printf("PyType_Ready(&p_dump_dir_type) < 0\n"); return; } + if (PyType_Ready(&p_run_event_state_type) < 0) + { + printf("PyType_Ready(&p_run_event_state_type) < 0\n"); + return; + } - m = Py_InitModule("_pyreport", module_methods); + PyObject *m = Py_InitModule("_pyreport", module_methods); //m = Py_InitModule3("_pyreport", module_methods, "Python wrapper for libreport"); if (!m) { @@ -60,9 +63,13 @@ init_pyreport(void) Py_INCREF(ReportError); PyModule_AddObject(m, "error", ReportError); + /* init type objects */ Py_INCREF(&p_crash_data_type); PyModule_AddObject(m, "crash_data", (PyObject *)&p_crash_data_type); Py_INCREF(&p_dump_dir_type); PyModule_AddObject(m, "dump_dir", (PyObject *)&p_dump_dir_type); + + Py_INCREF(&p_run_event_state_type); + PyModule_AddObject(m, "run_event_state", (PyObject *)&p_run_event_state_type); } -- cgit From 628fb1fbae2a9e3e8fc3add070bceb5557973029 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 16 Dec 2010 18:28:07 +0100 Subject: create_dump_dir: add base_dir_name parameter. This makes python wrappers more usable. src/report-python/test_full demonstrates how pyhton programs can run reporting now. Signed-off-by: Denys Vlasenko --- src/report-python/reportmodule.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/report-python/reportmodule.c') diff --git a/src/report-python/reportmodule.c b/src/report-python/reportmodule.c index db9f52d9..13184cc0 100644 --- a/src/report-python/reportmodule.c +++ b/src/report-python/reportmodule.c @@ -22,9 +22,10 @@ PyObject *ReportError; static PyMethodDef module_methods[] = { + /* method_name, func, flags, doc_string */ { "dd_opendir" , p_dd_opendir, METH_VARARGS, NULL }, { "dd_create" , p_dd_create, METH_VARARGS, NULL }, -// { "delete_dump_dir", p_delete_dump_dir, METH_VARARGS, NULL }, + { "delete_dump_dir", p_delete_dump_dir, METH_VARARGS, NULL }, { NULL } }; -- cgit From 639ebf76098f56ce33d9b774acc11f4a8e60be3d Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 22 Dec 2010 14:49:03 +0100 Subject: src/report-python: expose CD_FLAG_foo constants to Python wrapper Signed-off-by: Denys Vlasenko --- src/report-python/reportmodule.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/report-python/reportmodule.c') diff --git a/src/report-python/reportmodule.c b/src/report-python/reportmodule.c index 13184cc0..6dda73cf 100644 --- a/src/report-python/reportmodule.c +++ b/src/report-python/reportmodule.c @@ -19,6 +19,9 @@ #include #include "common.h" +#include "crash_data.h" +#include "dump_dir.h" + PyObject *ReportError; static PyMethodDef module_methods[] = { @@ -67,9 +70,16 @@ init_pyreport(void) /* init type objects */ Py_INCREF(&p_crash_data_type); PyModule_AddObject(m, "crash_data", (PyObject *)&p_crash_data_type); + PyModule_AddObject(m, "CD_FLAG_SYS" , Py_BuildValue("i", CD_FLAG_SYS )); + PyModule_AddObject(m, "CD_FLAG_BIN" , Py_BuildValue("i", CD_FLAG_BIN )); + PyModule_AddObject(m, "CD_FLAG_TXT" , Py_BuildValue("i", CD_FLAG_TXT )); + PyModule_AddObject(m, "CD_FLAG_ISEDITABLE" , Py_BuildValue("i", CD_FLAG_ISEDITABLE )); + PyModule_AddObject(m, "CD_FLAG_ISNOTEDITABLE", Py_BuildValue("i", CD_FLAG_ISNOTEDITABLE)); Py_INCREF(&p_dump_dir_type); PyModule_AddObject(m, "dump_dir", (PyObject *)&p_dump_dir_type); + PyModule_AddObject(m, "DD_FAIL_QUIETLY" , Py_BuildValue("i", DD_FAIL_QUIETLY )); + PyModule_AddObject(m, "DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE", Py_BuildValue("i", DD_LOAD_TEXT_RETURN_NULL_ON_FAILURE)); Py_INCREF(&p_run_event_state_type); PyModule_AddObject(m, "run_event_state", (PyObject *)&p_run_event_state_type); -- cgit From dba326f60e159697a740f08959d098e19c200453 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 22 Dec 2010 16:28:39 +0100 Subject: extend run_event() to run_event_on_dir_name() and run_event_on_crash_data() Signed-off-by: Denys Vlasenko --- src/report-python/reportmodule.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/report-python/reportmodule.c') diff --git a/src/report-python/reportmodule.c b/src/report-python/reportmodule.c index 6dda73cf..bd74cff3 100644 --- a/src/report-python/reportmodule.c +++ b/src/report-python/reportmodule.c @@ -17,18 +17,16 @@ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include -#include "common.h" -#include "crash_data.h" -#include "dump_dir.h" +#include "common.h" PyObject *ReportError; static PyMethodDef module_methods[] = { /* method_name, func, flags, doc_string */ - { "dd_opendir" , p_dd_opendir, METH_VARARGS, NULL }, - { "dd_create" , p_dd_create, METH_VARARGS, NULL }, - { "delete_dump_dir", p_delete_dump_dir, METH_VARARGS, NULL }, + { "dd_opendir" , p_dd_opendir , METH_VARARGS }, + { "dd_create" , p_dd_create , METH_VARARGS }, + { "delete_dump_dir", p_delete_dump_dir, METH_VARARGS }, { NULL } }; -- cgit From a330886781635606626b3b91432525128d0e8a8f Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Mon, 7 Feb 2011 11:54:07 +0100 Subject: get rid of unused CD_FLAG_SYS Signed-off-by: Nikola Pajkovsky --- src/report-python/reportmodule.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/report-python/reportmodule.c') diff --git a/src/report-python/reportmodule.c b/src/report-python/reportmodule.c index bd74cff3..fd58a3bd 100644 --- a/src/report-python/reportmodule.c +++ b/src/report-python/reportmodule.c @@ -68,7 +68,6 @@ init_pyreport(void) /* init type objects */ Py_INCREF(&p_crash_data_type); PyModule_AddObject(m, "crash_data", (PyObject *)&p_crash_data_type); - PyModule_AddObject(m, "CD_FLAG_SYS" , Py_BuildValue("i", CD_FLAG_SYS )); PyModule_AddObject(m, "CD_FLAG_BIN" , Py_BuildValue("i", CD_FLAG_BIN )); PyModule_AddObject(m, "CD_FLAG_TXT" , Py_BuildValue("i", CD_FLAG_TXT )); PyModule_AddObject(m, "CD_FLAG_ISEDITABLE" , Py_BuildValue("i", CD_FLAG_ISEDITABLE )); -- cgit