diff --git a/helloworld.py b/helloworld.py deleted file mode 100644 index 8e7e4d39..00000000 --- a/helloworld.py +++ /dev/null @@ -1,7 +0,0 @@ -import prof - -def prof_on_start(): - helloworld() - -def helloworld(): - prof.cons_show("Hello world!") diff --git a/plugins/helloworld.py b/plugins/helloworld.py new file mode 100644 index 00000000..33ecea68 --- /dev/null +++ b/plugins/helloworld.py @@ -0,0 +1,22 @@ +import prof + +package_version = None +package_status = None + +# hooks + +def prof_init(version, status): + global package_version + global package_status + package_version = version + package_status = status + +def prof_on_start(): + helloworld() + +# local functions + +def helloworld(): + global package_version + global package_status + prof.cons_show("Hello world! (" + package_version + " - " + package_status + ")") diff --git a/plugins/test.py b/plugins/test.py deleted file mode 100644 index a01e01e0..00000000 --- a/plugins/test.py +++ /dev/null @@ -1,2 +0,0 @@ -def plugin_name(): - return "plugin james" diff --git a/src/api/api.c b/src/api/api.c index c83aef1f..8fa18afd 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -45,7 +45,7 @@ static PyMethodDef apiMethods[] = { void api_init(void) { - PyObject *pName, *pModule, *pFunc; + PyObject *pName, *pModule, *pProfInit, *pProfOnStart, *pArgs; Py_Initialize(); Py_InitModule("prof", apiMethods); @@ -54,20 +54,20 @@ api_init(void) Py_DECREF(pName); if (pModule != NULL) { - - pFunc = PyObject_GetAttrString(pModule, "prof_on_start"); - - if (pFunc == NULL) { - cons_show("NULL pfunc"); + pProfInit = PyObject_GetAttrString(pModule, "prof_init"); + if (pProfInit && PyCallable_Check(pProfInit)) { + pArgs = Py_BuildValue("ss", PACKAGE_VERSION, PACKAGE_STATUS); + PyObject_CallObject(pProfInit, pArgs); +// Py_XDECREF(pArgs); } + Py_XDECREF(pProfInit); - if (pFunc && PyCallable_Check(pFunc)) { - PyObject_CallObject(pFunc, NULL); + pProfOnStart = PyObject_GetAttrString(pModule, "prof_on_start"); + if (pProfOnStart && PyCallable_Check(pProfOnStart)) { + PyObject_CallObject(pProfOnStart, NULL); } - else { - cons_show("Could not find function"); - } - Py_XDECREF(pFunc); + Py_XDECREF(pProfOnStart); + Py_DECREF(pModule); } else {