systemd-python: export sd_journal_get_usage
This commit is contained in:
parent
742af54adc
commit
50a279f857
1
TODO
1
TODO
|
@ -586,7 +586,6 @@ Features:
|
||||||
* systemd-python:
|
* systemd-python:
|
||||||
- allow reading of only select fields in systemd.journal._reader.Reader
|
- allow reading of only select fields in systemd.journal._reader.Reader
|
||||||
- export sd_journal_test_cursor in systemd.journal._reader.Reader
|
- export sd_journal_test_cursor in systemd.journal._reader.Reader
|
||||||
- export sd_journal_get_usage in systemd.journal._reader.Reader
|
|
||||||
- figure out a simple way to wait for journal events in a way that
|
- figure out a simple way to wait for journal events in a way that
|
||||||
works with ^C
|
works with ^C
|
||||||
- add documentation to systemd.daemon
|
- add documentation to systemd.daemon
|
||||||
|
|
|
@ -64,12 +64,12 @@
|
||||||
<title>Description</title>
|
<title>Description</title>
|
||||||
|
|
||||||
<para><function>sd_journal_get_usage()</function>
|
<para><function>sd_journal_get_usage()</function>
|
||||||
determines the total disk space currently used up by
|
determines the total disk space currently used by
|
||||||
journal files. If
|
journal files (in bytes). If
|
||||||
<literal>SD_JOURNAL_LOCAL_ONLY</literal> has been
|
<literal>SD_JOURNAL_LOCAL_ONLY</literal> was passed
|
||||||
passed when opening the journal files this value will
|
when opening the journal this value will only reflect
|
||||||
only reflect the size of journal files of the local
|
the size of journal files of the local host, otherwise
|
||||||
host, otherwise of all hosts.</para>
|
of all hosts.</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
|
|
|
@ -130,12 +130,12 @@ PyDoc_STRVAR(Reader_fileno__doc__,
|
||||||
"See man:sd_journal_get_fd(3).");
|
"See man:sd_journal_get_fd(3).");
|
||||||
static PyObject* Reader_fileno(Reader *self, PyObject *args)
|
static PyObject* Reader_fileno(Reader *self, PyObject *args)
|
||||||
{
|
{
|
||||||
int r;
|
int fd;
|
||||||
r = sd_journal_get_fd(self->j);
|
fd = sd_journal_get_fd(self->j);
|
||||||
set_error(r, NULL, NULL);
|
set_error(fd, NULL, NULL);
|
||||||
if (r < 0)
|
if (fd < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return long_FromLong(r);
|
return long_FromLong(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,6 +171,29 @@ static PyObject* Reader_close(Reader *self, PyObject *args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PyDoc_STRVAR(Reader_get_usage__doc__,
|
||||||
|
"get_usage() -> int\n\n"
|
||||||
|
"Returns the total disk space currently used by journal"
|
||||||
|
"files (in bytes). If `SD_JOURNAL_LOCAL_ONLY` was"
|
||||||
|
"passed when opening the journal this value will only reflect"
|
||||||
|
"the size of journal files of the local host, otherwise"
|
||||||
|
"of all hosts.\n\n"
|
||||||
|
"This method invokes sd_journal_get_usage().\n"
|
||||||
|
"See man:sd_journal_get_usage(3).");
|
||||||
|
static PyObject* Reader_get_usage(Reader *self, PyObject *args)
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
uint64_t bytes;
|
||||||
|
|
||||||
|
r = sd_journal_get_usage(self->j, &bytes);
|
||||||
|
if (set_error(r, NULL, NULL))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
assert_cc(sizeof(unsigned long long) == sizeof(bytes));
|
||||||
|
return PyLong_FromUnsignedLongLong(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PyDoc_STRVAR(Reader___enter____doc__,
|
PyDoc_STRVAR(Reader___enter____doc__,
|
||||||
"__enter__() -> self\n\n"
|
"__enter__() -> self\n\n"
|
||||||
"Part of the context manager protocol.\n"
|
"Part of the context manager protocol.\n"
|
||||||
|
@ -770,9 +793,9 @@ static PyMethodDef Reader_methods[] = {
|
||||||
{"fileno", (PyCFunction) Reader_fileno, METH_NOARGS, Reader_fileno__doc__},
|
{"fileno", (PyCFunction) Reader_fileno, METH_NOARGS, Reader_fileno__doc__},
|
||||||
{"reliable_fd", (PyCFunction) Reader_reliable_fd, METH_NOARGS, Reader_reliable_fd__doc__},
|
{"reliable_fd", (PyCFunction) Reader_reliable_fd, METH_NOARGS, Reader_reliable_fd__doc__},
|
||||||
{"close", (PyCFunction) Reader_close, METH_NOARGS, Reader_close__doc__},
|
{"close", (PyCFunction) Reader_close, METH_NOARGS, Reader_close__doc__},
|
||||||
|
{"get_usage", (PyCFunction) Reader_get_usage, METH_NOARGS, Reader_get_usage__doc__},
|
||||||
{"__enter__", (PyCFunction) Reader___enter__, METH_NOARGS, Reader___enter____doc__},
|
{"__enter__", (PyCFunction) Reader___enter__, METH_NOARGS, Reader___enter____doc__},
|
||||||
{"__exit__", (PyCFunction) Reader___exit__, METH_VARARGS, Reader___exit____doc__},
|
{"__exit__", (PyCFunction) Reader___exit__, METH_VARARGS, Reader___exit____doc__},
|
||||||
{"close", (PyCFunction) Reader_close, METH_NOARGS, Reader_close__doc__},
|
|
||||||
{"get_next", (PyCFunction) Reader_get_next, METH_VARARGS, Reader_get_next__doc__},
|
{"get_next", (PyCFunction) Reader_get_next, METH_VARARGS, Reader_get_next__doc__},
|
||||||
{"get_previous", (PyCFunction) Reader_get_previous, METH_VARARGS, Reader_get_previous__doc__},
|
{"get_previous", (PyCFunction) Reader_get_previous, METH_VARARGS, Reader_get_previous__doc__},
|
||||||
{"add_match", (PyCFunction) Reader_add_match, METH_VARARGS|METH_KEYWORDS, Reader_add_match__doc__},
|
{"add_match", (PyCFunction) Reader_add_match, METH_VARARGS|METH_KEYWORDS, Reader_add_match__doc__},
|
||||||
|
|
Loading…
Reference in a new issue