mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Hmmm something is wrong here with the Python interpreter
Former-commit-id: bfa87ac83ae1518348e5fe1ed77f20475134e1b0
This commit is contained in:
parent
c18920b59e
commit
45e4aff5f1
@ -12,7 +12,6 @@
|
|||||||
PyMethodDef Effect::effectMethods[] = {
|
PyMethodDef Effect::effectMethods[] = {
|
||||||
{"setColor", Effect::wrapSetColor, METH_VARARGS, "Set a new color for the leds."},
|
{"setColor", Effect::wrapSetColor, METH_VARARGS, "Set a new color for the leds."},
|
||||||
{"setImage", Effect::wrapSetImage, METH_VARARGS, "Set a new image to process and determine new led colors."},
|
{"setImage", Effect::wrapSetImage, METH_VARARGS, "Set a new image to process and determine new led colors."},
|
||||||
{"getLedCount", Effect::wrapGetLedCount, METH_NOARGS, "Get the number of avaliable led channels."},
|
|
||||||
{"abort", Effect::wrapAbort, METH_NOARGS, "Check if the effect should abort execution."},
|
{"abort", Effect::wrapAbort, METH_NOARGS, "Check if the effect should abort execution."},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
@ -43,7 +42,10 @@ void Effect::run()
|
|||||||
|
|
||||||
// add methods extra builtin methods to the interpreter
|
// add methods extra builtin methods to the interpreter
|
||||||
PyObject * thisCapsule = PyCapsule_New(this, nullptr, nullptr);
|
PyObject * thisCapsule = PyCapsule_New(this, nullptr, nullptr);
|
||||||
Py_InitModule4("hyperion", effectMethods, nullptr, thisCapsule, PYTHON_API_VERSION);
|
PyObject * module = Py_InitModule4("hyperion", effectMethods, nullptr, thisCapsule, PYTHON_API_VERSION);
|
||||||
|
|
||||||
|
// add ledCount variable to the interpreter
|
||||||
|
PyObject_SetAttrString(module, "ledCount", Py_BuildValue("i", _imageProcessor->getLedCount()));
|
||||||
|
|
||||||
// Set the end time if applicable
|
// Set the end time if applicable
|
||||||
if (_timeout > 0)
|
if (_timeout > 0)
|
||||||
@ -89,12 +91,6 @@ PyObject* Effect::wrapSetImage(PyObject *self, PyObject *args)
|
|||||||
return Py_BuildValue("i", 42);
|
return Py_BuildValue("i", 42);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject* Effect::wrapGetLedCount(PyObject *self, PyObject *args)
|
|
||||||
{
|
|
||||||
Effect * effect = getEffect(self);
|
|
||||||
return Py_BuildValue("i", effect->_imageProcessor->getLedCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
PyObject* Effect::wrapAbort(PyObject *self, PyObject *)
|
PyObject* Effect::wrapAbort(PyObject *self, PyObject *)
|
||||||
{
|
{
|
||||||
Effect * effect = getEffect(self);
|
Effect * effect = getEffect(self);
|
||||||
|
@ -35,7 +35,6 @@ private:
|
|||||||
static PyMethodDef effectMethods[];
|
static PyMethodDef effectMethods[];
|
||||||
static PyObject* wrapSetColor(PyObject *self, PyObject *args);
|
static PyObject* wrapSetColor(PyObject *self, PyObject *args);
|
||||||
static PyObject* wrapSetImage(PyObject *self, PyObject *args);
|
static PyObject* wrapSetImage(PyObject *self, PyObject *args);
|
||||||
static PyObject* wrapGetLedCount(PyObject *self, PyObject *args);
|
|
||||||
static PyObject* wrapAbort(PyObject *self, PyObject *args);
|
static PyObject* wrapAbort(PyObject *self, PyObject *args);
|
||||||
static Effect * getEffect(PyObject *self);
|
static Effect * getEffect(PyObject *self);
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
#include <effectengine/EffectEngine.h>
|
#include <effectengine/EffectEngine.h>
|
||||||
#include "Effect.h"
|
#include "Effect.h"
|
||||||
|
|
||||||
|
//static PyThreadState *_mainThreadState = 0;
|
||||||
|
|
||||||
EffectEngine::EffectEngine(Hyperion * hyperion) :
|
EffectEngine::EffectEngine(Hyperion * hyperion) :
|
||||||
_hyperion(hyperion),
|
_hyperion(hyperion),
|
||||||
_availableEffects(),
|
_availableEffects(),
|
||||||
@ -21,6 +23,7 @@ EffectEngine::EffectEngine(Hyperion * hyperion) :
|
|||||||
std::cout << "Initializing Python interpreter" << std::endl;
|
std::cout << "Initializing Python interpreter" << std::endl;
|
||||||
Py_InitializeEx(0);
|
Py_InitializeEx(0);
|
||||||
PyEval_InitThreads(); // Create the GIL
|
PyEval_InitThreads(); // Create the GIL
|
||||||
|
//_mainThreadState = PyEval_SaveThread();
|
||||||
PyEval_ReleaseLock(); // Release the GIL
|
PyEval_ReleaseLock(); // Release the GIL
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,7 +32,8 @@ EffectEngine::~EffectEngine()
|
|||||||
// clean up the Python interpreter
|
// clean up the Python interpreter
|
||||||
std::cout << "Cleaning up Python interpreter" << std::endl;
|
std::cout << "Cleaning up Python interpreter" << std::endl;
|
||||||
PyEval_AcquireLock(); // Get the Gil
|
PyEval_AcquireLock(); // Get the Gil
|
||||||
Py_Finalize();
|
//PyEval_RestoreThread(_mainThreadState);
|
||||||
|
//Py_Finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<std::string> EffectEngine::getEffects() const
|
std::list<std::string> EffectEngine::getEffects() const
|
||||||
|
Loading…
Reference in New Issue
Block a user