chiark / gitweb /
systemd-python: add _Reader.get_catalog()
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 15 Mar 2013 22:10:51 +0000 (18:10 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 20 Mar 2013 01:50:42 +0000 (21:50 -0400)
This one wraps sd_journaal_get_catalog.

TODO
src/python-systemd/_reader.c

diff --git a/TODO b/TODO
index 715dd9dbc8f13dcca5a661b346181bb081166f17..750540fb12797c1ca60f7a16eec49aad5b43623d 100644 (file)
--- a/TODO
+++ b/TODO
@@ -581,7 +581,6 @@ Features:
 * drop cap bounding set in readahead and other services
 
 * systemd-python:
-   - export sd_journal_get_catalog (in systemd.journal._reader)
    - export sd_journal_get_catalog_for_message_id (in systemd.id128)
    - allow reading of only select fields in systemd.journal._reader.Reader
    - export sd_journal_test_cursor in systemd.journal._reader.Reader
index 67358e3061d536f2a6b68ceafd8b53b682be3860..a257757e127187404f6754a890678d70949b78ea 100644 (file)
@@ -634,6 +634,29 @@ static PyObject* Reader_query_unique(Reader *self, PyObject *args)
     return value_set;
 }
 
+
+PyDoc_STRVAR(Reader_get_catalog__doc__,
+             "get_catalog() -> str\n\n"
+             "Retrieve a message catalog entry for the current journal entry.\n"
+             "Wraps man:sd_journal_get_catalog(3).");
+static PyObject* Reader_get_catalog(Reader *self, PyObject *args)
+{
+    int r;
+    char _cleanup_free_ *msg = NULL;
+
+    assert(self);
+    assert(!args);
+
+    Py_BEGIN_ALLOW_THREADS
+    r = sd_journal_get_catalog(self->j, &msg);
+    Py_END_ALLOW_THREADS
+    if (set_error(r, NULL, NULL))
+        return NULL;
+
+    return unicode_FromString(msg);
+}
+
+
 PyDoc_STRVAR(data_threshold__doc__,
              "Threshold for field size truncation in bytes.\n\n"
              "Fields longer than this will be truncated to the threshold size.\n"
@@ -706,6 +729,7 @@ static PyMethodDef Reader_methods[] = {
     {"wait",            (PyCFunction) Reader_wait, METH_VARARGS, Reader_wait__doc__},
     {"seek_cursor",     (PyCFunction) Reader_seek_cursor, METH_VARARGS, Reader_seek_cursor__doc__},
     {"query_unique",    (PyCFunction) Reader_query_unique, METH_VARARGS, Reader_query_unique__doc__},
+    {"get_catalog",     (PyCFunction) Reader_get_catalog, METH_NOARGS, Reader_get_catalog__doc__},
     {NULL}  /* Sentinel */
 };