aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/python/alarms.c47
1 files changed, 28 insertions, 19 deletions
diff --git a/lib/python/alarms.c b/lib/python/alarms.c
index 2c42d52..2673bed 100644
--- a/lib/python/alarms.c
+++ b/lib/python/alarms.c
@@ -14,12 +14,12 @@
#include "pyalarmd_proto.h"
static PyMethodDef ExportedMethods[] = {
- {"connect" , pyalarmd_connect , METH_VARARGS, "Open a connection to the named socket at the given path, returning the fd associated with it."},
- {"disconnect" , pyalarmd_disconnect, METH_VARARGS, "Close a socket fd previously returned by connect(path)."},
- {"register_alarm" , pyalarmd_register , METH_VARARGS, "Send a request over the given socket to register an alarm with the given name. Returns the UUID of the new alarm as a string"},
- {"deregister_alarm", pyalarmd_deregister, METH_VARARGS, "Send a request over the given socket to deregister an alarm with the given UUID."},
- {"raise_alarm" , pyalarmd_raise , METH_VARARGS, "Send a request over the given socket to raise the alarm with the given UUID."},
- {"clear_alarm" , pyalarmd_clear , METH_VARARGS, "Send a request over the given socket to clear/lower the alarm with the given UUID."},
+ {"connect" , (PyCFunction)pyalarmd_connect , METH_VARARGS|METH_KEYWORDS, "Open a connection to the named socket at the given path, returning the fd associated with it."},
+ {"disconnect" , (PyCFunction)pyalarmd_disconnect, METH_VARARGS|METH_KEYWORDS, "Close a socket fd previously returned by connect(path)."},
+ {"register_alarm" , (PyCFunction)pyalarmd_register , METH_VARARGS|METH_KEYWORDS, "Send a request over the given socket to register an alarm with the given name. Returns the UUID of the new alarm as a string"},
+ {"deregister_alarm", (PyCFunction)pyalarmd_deregister, METH_VARARGS|METH_KEYWORDS, "Send a request over the given socket to deregister an alarm with the given UUID."},
+ {"raise_alarm" , (PyCFunction)pyalarmd_raise , METH_VARARGS|METH_KEYWORDS, "Send a request over the given socket to raise the alarm with the given UUID."},
+ {"clear_alarm" , (PyCFunction)pyalarmd_clear , METH_VARARGS|METH_KEYWORDS, "Send a request over the given socket to clear/lower the alarm with the given UUID."},
{NULL , NULL , 0 , NULL }
};
@@ -34,7 +34,8 @@ static struct PyModuleDef alarm_python = {
static PyObject *alarmd_error;
-PyObject* PyInit_alarms(void) {
+PyObject* PyInit_alarms(void)
+{
PyObject *module = NULL;
module = PyModule_Create(&alarm_python);
@@ -44,12 +45,14 @@ PyObject* PyInit_alarms(void) {
return module;
}
-PyObject* pyalarmd_connect(PyObject *self, PyObject *args) {
+PyObject* pyalarmd_connect(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ char *kwlist[] = {"path", NULL};
const char *path = NULL;
int sock = 0;
struct sockaddr_un server;
- if (!PyArg_ParseTuple(args, "s", &path)) {
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "s", kwlist, &path)) {
return NULL;
}
@@ -68,10 +71,12 @@ PyObject* pyalarmd_connect(PyObject *self, PyObject *args) {
return PyLong_FromLong(sock);
}
-PyObject* pyalarmd_disconnect(PyObject *self, PyObject *args) {
+PyObject* pyalarmd_disconnect(PyObject *self, PyObject *args, PyObject *keywds)
+{
+ char *kwlist[] = {"socket", NULL};
int sock = 0;
- if (!PyArg_ParseTuple(args, "i", &sock)) {
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "i", kwlist, &sock)) {
return NULL;
}
@@ -80,14 +85,15 @@ PyObject* pyalarmd_disconnect(PyObject *self, PyObject *args) {
Py_RETURN_NONE;
}
-PyObject* pyalarmd_register(PyObject *self, PyObject *args)
+PyObject* pyalarmd_register(PyObject *self, PyObject *args, PyObject *keywds)
{
+ char *kwlist[] = {"socket", "description", NULL};
int sock = 0;
char *desc;
char uuid_str[37];
uuid_t uuid;
- if (!PyArg_ParseTuple(args, "is", &sock, &desc)) {
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "is", kwlist, &sock, &desc)) {
return NULL;
}
@@ -101,13 +107,14 @@ PyObject* pyalarmd_register(PyObject *self, PyObject *args)
return Py_BuildValue("s", uuid_str);
}
-PyObject* pyalarmd_deregister(PyObject *self, PyObject *args)
+PyObject* pyalarmd_deregister(PyObject *self, PyObject *args, PyObject *keywds)
{
+ char *kwlist[] = {"socket", "uuid", NULL};
int sock = 0;
char *uuid_str = NULL;
uuid_t uuid;
- if (!PyArg_ParseTuple(args, "is", &sock, &uuid_str)) {
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "is", kwlist, &sock, &uuid_str)) {
return NULL;
}
@@ -124,13 +131,14 @@ PyObject* pyalarmd_deregister(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
-PyObject* pyalarmd_raise(PyObject *self, PyObject *args)
+PyObject* pyalarmd_raise(PyObject *self, PyObject *args, PyObject *keywds)
{
+ char *kwlist[] = {"socket", "uuid", NULL};
int sock = 0;
char *uuid_str = NULL;
uuid_t uuid;
- if (!PyArg_ParseTuple(args, "is", &sock, &uuid_str)) {
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "is", kwlist, &sock, &uuid_str)) {
return NULL;
}
@@ -147,13 +155,14 @@ PyObject* pyalarmd_raise(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
-PyObject* pyalarmd_clear(PyObject *self, PyObject *args)
+PyObject* pyalarmd_clear(PyObject *self, PyObject *args, PyObject *keywds)
{
+ char *kwlist[] = {"socket", "uuid", NULL};
int sock = 0;
char *uuid_str = NULL;
uuid_t uuid;
- if (!PyArg_ParseTuple(args, "is", &sock, &uuid_str)) {
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "is", kwlist, &sock, &uuid_str)) {
return NULL;
}