mirror of https://git.kore.io/kore.git
allow python modules to set progname.
This commit is contained in:
parent
88bd3ce045
commit
f2472ba485
|
@ -43,6 +43,7 @@ static PyObject *python_kore_queue(PyObject *, PyObject *);
|
|||
static PyObject *python_kore_worker(PyObject *, PyObject *);
|
||||
static PyObject *python_kore_tracer(PyObject *, PyObject *);
|
||||
static PyObject *python_kore_fatalx(PyObject *, PyObject *);
|
||||
static PyObject *python_kore_setname(PyObject *, PyObject *);
|
||||
static PyObject *python_kore_suspend(PyObject *, PyObject *);
|
||||
static PyObject *python_kore_shutdown(PyObject *, PyObject *);
|
||||
static PyObject *python_kore_bind_unix(PyObject *, PyObject *);
|
||||
|
@ -82,6 +83,7 @@ static struct PyMethodDef pykore_methods[] = {
|
|||
METHOD("gather", python_kore_gather, METH_VARARGS | METH_KEYWORDS),
|
||||
METHOD("fatal", python_kore_fatal, METH_VARARGS),
|
||||
METHOD("fatalx", python_kore_fatalx, METH_VARARGS),
|
||||
METHOD("setname", python_kore_setname, METH_VARARGS),
|
||||
METHOD("suspend", python_kore_suspend, METH_VARARGS),
|
||||
METHOD("shutdown", python_kore_shutdown, METH_NOARGS),
|
||||
METHOD("bind_unix", python_kore_bind_unix, METH_VARARGS),
|
||||
|
|
|
@ -335,9 +335,12 @@ static const char *python_config_data =
|
|||
"}\n";
|
||||
|
||||
static const char *python_init_data =
|
||||
"import kore\n"
|
||||
"from .app import koreapp\n"
|
||||
"\n"
|
||||
"def kore_parent_configure(args):\n"
|
||||
" if hasattr(koreapp, \"_appname\"):\n"
|
||||
" kore.setname(koreapp._appname)\n"
|
||||
" koreapp.configure(args)\n"
|
||||
"\n"
|
||||
"def kore_worker_configure():\n"
|
||||
|
|
15
src/python.c
15
src/python.c
|
@ -1410,6 +1410,21 @@ python_kore_fatalx(PyObject *self, PyObject *args)
|
|||
Py_RETURN_TRUE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
python_kore_setname(PyObject *self, PyObject *args)
|
||||
{
|
||||
const char *name;
|
||||
extern char *kore_progname;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s", &name))
|
||||
return (NULL);
|
||||
|
||||
kore_free(kore_progname);
|
||||
kore_progname = kore_strdup(name);
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
python_kore_suspend(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue