Skip to content

Commit c80d51e

Browse files
author
Alexandre Bonnetain
committed
Add a mule_file method to the Python API
1 parent ec8985c commit c80d51e

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

plugins/python/uwsgi_pymodule.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,27 @@ PyObject *py_uwsgi_mule_get_msg(PyObject * self, PyObject * args, PyObject *kwar
14881488
return msg;
14891489
}
14901490

1491+
PyObject *py_uwsgi_mule_file(PyObject * self, PyObject * args) {
1492+
1493+
int mule_id = uwsgi.muleid;
1494+
1495+
if (PyArg_ParseTuple(args, "|i", &mule_id) && mule_id == 0) {
1496+
return NULL;
1497+
}
1498+
1499+
if (uwsgi.mules_cnt < mule_id && mule_id > 0) {
1500+
return PyErr_Format(PyExc_ValueError, "The id you provided doesn't correspond to any mule");
1501+
}
1502+
1503+
struct uwsgi_mule *mule = get_mule_by_id(mule_id);
1504+
if (!mule || !mule->patch) {
1505+
Py_INCREF(Py_None);
1506+
return Py_None;
1507+
}
1508+
1509+
return PyString_FromString(mule->patch);
1510+
}
1511+
14911512
PyObject *py_uwsgi_farm_get_msg(PyObject * self, PyObject * args) {
14921513

14931514
ssize_t len = 0;
@@ -2815,6 +2836,8 @@ static PyMethodDef uwsgi_advanced_methods[] = {
28152836

28162837
{"micros", py_uwsgi_micros, METH_VARARGS, ""},
28172838

2839+
{"mule_file", py_uwsgi_mule_file, METH_VARARGS, ""},
2840+
28182841
{NULL, NULL},
28192842
};
28202843

0 commit comments

Comments
 (0)