mirror of
https://github.com/systemd/systemd.git
synced 2025-02-23 13:57:33 +03:00
python: reindent _reader.c
All files should follow our coding style, and that means 8ch indenting. Let's correct that.
This commit is contained in:
parent
8fca4e305f
commit
41736b25a7
@ -1,4 +1,4 @@
|
||||
/*-*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*-*/
|
||||
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
|
||||
|
||||
/***
|
||||
This file is part of systemd.
|
||||
@ -39,7 +39,6 @@ typedef struct {
|
||||
} Reader;
|
||||
static PyTypeObject ReaderType;
|
||||
|
||||
|
||||
PyDoc_STRVAR(module__doc__,
|
||||
"Class to reads the systemd journal similar to journalctl.");
|
||||
|
||||
@ -180,47 +179,49 @@ static int Reader_init(Reader *self, PyObject *args, PyObject *keywds) {
|
||||
return set_error(r, path, "Invalid flags or path");
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_fileno__doc__,
|
||||
"fileno() -> int\n\n"
|
||||
"Get a file descriptor to poll for changes in the journal.\n"
|
||||
"This method invokes sd_journal_get_fd().\n"
|
||||
"See man:sd_journal_get_fd(3).");
|
||||
static PyObject* Reader_fileno(Reader *self, PyObject *args) {
|
||||
int fd = sd_journal_get_fd(self->j);
|
||||
int fd;
|
||||
|
||||
fd = sd_journal_get_fd(self->j);
|
||||
set_error(fd, NULL, NULL);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
return long_FromLong(fd);
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_reliable_fd__doc__,
|
||||
"reliable_fd() -> bool\n\n"
|
||||
"Returns True iff the journal can be polled reliably.\n"
|
||||
"This method invokes sd_journal_reliable_fd().\n"
|
||||
"See man:sd_journal_reliable_fd(3).");
|
||||
static PyObject* Reader_reliable_fd(Reader *self, PyObject *args) {
|
||||
int r = sd_journal_reliable_fd(self->j);
|
||||
int r;
|
||||
|
||||
r = sd_journal_reliable_fd(self->j);
|
||||
if (set_error(r, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
return PyBool_FromLong(r);
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_get_events__doc__,
|
||||
"get_events() -> int\n\n"
|
||||
"Returns a mask of poll() events to wait for on the file\n"
|
||||
"descriptor returned by .fileno().\n\n"
|
||||
"See man:sd_journal_get_events(3) for further discussion.");
|
||||
static PyObject* Reader_get_events(Reader *self, PyObject *args) {
|
||||
int r = sd_journal_get_events(self->j);
|
||||
int r;
|
||||
|
||||
r = sd_journal_get_events(self->j);
|
||||
if (set_error(r, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
return long_FromLong(r);
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_get_timeout__doc__,
|
||||
"get_timeout() -> int or None\n\n"
|
||||
"Returns a timeout value for usage in poll(), the time since the\n"
|
||||
@ -244,7 +245,6 @@ static PyObject* Reader_get_timeout(Reader *self, PyObject *args) {
|
||||
return PyLong_FromUnsignedLongLong(t);
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_get_timeout_ms__doc__,
|
||||
"get_timeout_ms() -> int\n\n"
|
||||
"Returns a timeout value suitable for usage in poll(), the value\n"
|
||||
@ -261,7 +261,6 @@ static PyObject* Reader_get_timeout_ms(Reader *self, PyObject *args) {
|
||||
return absolute_timeout(t);
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_close__doc__,
|
||||
"close() -> None\n\n"
|
||||
"Free resources allocated by this Reader object.\n"
|
||||
@ -276,7 +275,6 @@ static PyObject* Reader_close(Reader *self, PyObject *args) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_get_usage__doc__,
|
||||
"get_usage() -> int\n\n"
|
||||
"Returns the total disk space currently used by journal\n"
|
||||
@ -298,7 +296,6 @@ static PyObject* Reader_get_usage(Reader *self, PyObject *args) {
|
||||
return PyLong_FromUnsignedLongLong(bytes);
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader___enter____doc__,
|
||||
"__enter__() -> self\n\n"
|
||||
"Part of the context manager protocol.\n"
|
||||
@ -319,7 +316,6 @@ static PyObject* Reader___exit__(Reader *self, PyObject *args) {
|
||||
return Reader_close(self, args);
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_next__doc__,
|
||||
"next([skip]) -> bool\n\n"
|
||||
"Go to the next log entry. Optional skip value means to go to\n"
|
||||
@ -369,7 +365,6 @@ static PyObject* Reader_previous(Reader *self, PyObject *args) {
|
||||
(char*) "L", -skip);
|
||||
}
|
||||
|
||||
|
||||
static int extract(const char* msg, size_t msg_len,
|
||||
PyObject **key, PyObject **value) {
|
||||
PyObject *k = NULL, *v;
|
||||
@ -436,7 +431,6 @@ static PyObject* Reader_get(Reader *self, PyObject *args) {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_get_all__doc__,
|
||||
"_get_all() -> dict\n\n"
|
||||
"Return dictionary of the current log entry.");
|
||||
@ -495,7 +489,6 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_get_realtime__doc__,
|
||||
"get_realtime() -> int\n\n"
|
||||
"Return the realtime timestamp for the current journal entry\n"
|
||||
@ -517,7 +510,6 @@ static PyObject* Reader_get_realtime(Reader *self, PyObject *args) {
|
||||
return PyLong_FromUnsignedLongLong(timestamp);
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_get_monotonic__doc__,
|
||||
"get_monotonic() -> (timestamp, bootid)\n\n"
|
||||
"Return the monotonic timestamp for the current journal entry\n"
|
||||
@ -582,7 +574,6 @@ static PyObject* Reader_add_match(Reader *self, PyObject *args, PyObject *keywds
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_add_disjunction__doc__,
|
||||
"add_disjunction() -> None\n\n"
|
||||
"Inserts a logical OR between matches added since previous\n"
|
||||
@ -597,7 +588,6 @@ static PyObject* Reader_add_disjunction(Reader *self, PyObject *args) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_add_conjunction__doc__,
|
||||
"add_conjunction() -> None\n\n"
|
||||
"Inserts a logical AND between matches added since previous\n"
|
||||
@ -612,7 +602,6 @@ static PyObject* Reader_add_conjunction(Reader *self, PyObject *args) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_flush_matches__doc__,
|
||||
"flush_matches() -> None\n\n"
|
||||
"Clear all current match filters.");
|
||||
@ -621,7 +610,6 @@ static PyObject* Reader_flush_matches(Reader *self, PyObject *args) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_seek_head__doc__,
|
||||
"seek_head() -> None\n\n"
|
||||
"Jump to the beginning of the journal.\n"
|
||||
@ -632,12 +620,13 @@ static PyObject* Reader_seek_head(Reader *self, PyObject *args) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
r = sd_journal_seek_head(self->j);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (set_error(r, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_seek_tail__doc__,
|
||||
"seek_tail() -> None\n\n"
|
||||
"Jump to the end of the journal.\n"
|
||||
@ -645,15 +634,16 @@ PyDoc_STRVAR(Reader_seek_tail__doc__,
|
||||
"See man:sd_journal_seek_tail(3).");
|
||||
static PyObject* Reader_seek_tail(Reader *self, PyObject *args) {
|
||||
int r;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
r = sd_journal_seek_tail(self->j);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (set_error(r, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_seek_realtime__doc__,
|
||||
"seek_realtime(realtime) -> None\n\n"
|
||||
"Seek to nearest matching journal entry to `realtime`. Argument\n"
|
||||
@ -668,12 +658,13 @@ static PyObject* Reader_seek_realtime(Reader *self, PyObject *args) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
r = sd_journal_seek_realtime_usec(self->j, timestamp);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (set_error(r, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_seek_monotonic__doc__,
|
||||
"seek_monotonic(monotonic[, bootid]) -> None\n\n"
|
||||
"Seek to nearest matching journal entry to `monotonic`. Argument\n"
|
||||
@ -697,6 +688,7 @@ static PyObject* Reader_seek_monotonic(Reader *self, PyObject *args) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
r = sd_id128_get_boot(&id);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (set_error(r, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
}
|
||||
@ -704,6 +696,7 @@ static PyObject* Reader_seek_monotonic(Reader *self, PyObject *args) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
r = sd_journal_seek_monotonic_usec(self->j, id, timestamp);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (set_error(r, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
|
||||
@ -733,7 +726,6 @@ static PyObject* Reader_process(Reader *self, PyObject *args) {
|
||||
return long_FromLong(r);
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_wait__doc__,
|
||||
"wait([timeout]) -> state change (integer)\n\n"
|
||||
"Wait for a change in the journal. Argument `timeout` specifies\n"
|
||||
@ -754,13 +746,13 @@ static PyObject* Reader_wait(Reader *self, PyObject *args) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
r = sd_journal_wait(self->j, timeout);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (set_error(r, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
|
||||
return long_FromLong(r);
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_seek_cursor__doc__,
|
||||
"seek_cursor(cursor) -> None\n\n"
|
||||
"Seek to journal entry by given unique reference `cursor`.");
|
||||
@ -774,12 +766,13 @@ static PyObject* Reader_seek_cursor(Reader *self, PyObject *args) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
r = sd_journal_seek_cursor(self->j, cursor);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (set_error(r, NULL, "Invalid cursor") < 0)
|
||||
return NULL;
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_get_cursor__doc__,
|
||||
"get_cursor() -> str\n\n"
|
||||
"Return a cursor string for the current journal entry.\n\n"
|
||||
@ -798,7 +791,6 @@ static PyObject* Reader_get_cursor(Reader *self, PyObject *args) {
|
||||
return unicode_FromString(cursor);
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(Reader_test_cursor__doc__,
|
||||
"test_cursor(str) -> bool\n\n"
|
||||
"Test whether the cursor string matches current journal entry.\n\n"
|
||||
@ -837,6 +829,7 @@ static PyObject* Reader_query_unique(Reader *self, PyObject *args) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
r = sd_journal_query_unique(self->j, query);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (set_error(r, NULL, "Invalid field name") < 0)
|
||||
return NULL;
|
||||
|
||||
@ -853,11 +846,11 @@ static PyObject* Reader_query_unique(Reader *self, PyObject *args) {
|
||||
PySet_Add(value_set, value);
|
||||
Py_DECREF(value);
|
||||
}
|
||||
|
||||
Py_DECREF(key);
|
||||
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"
|
||||
@ -875,6 +868,7 @@ static PyObject* Reader_get_catalog(Reader *self, PyObject *args) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
r = sd_journal_get_catalog(self->j, &msg);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (r == -ENOENT) {
|
||||
const void* mid;
|
||||
size_t mid_len;
|
||||
@ -891,13 +885,13 @@ static PyObject* Reader_get_catalog(Reader *self, PyObject *args) {
|
||||
set_error(r, NULL, NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (set_error(r, NULL, NULL) < 0)
|
||||
return NULL;
|
||||
|
||||
return unicode_FromString(msg);
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(get_catalog__doc__,
|
||||
"get_catalog(id128) -> str\n\n"
|
||||
"Retrieve a message catalog entry for the given id.\n"
|
||||
@ -921,13 +915,13 @@ static PyObject* get_catalog(PyObject *self, PyObject *args) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
r = sd_journal_get_catalog_for_message_id(id, &msg);
|
||||
Py_END_ALLOW_THREADS
|
||||
|
||||
if (set_error(r, NULL, NULL) < 0)
|
||||
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"
|
||||
@ -946,37 +940,38 @@ static PyObject* Reader_get_data_threshold(Reader *self, void *closure) {
|
||||
|
||||
static int Reader_set_data_threshold(Reader *self, PyObject *value, void *closure) {
|
||||
int r;
|
||||
|
||||
if (value == NULL) {
|
||||
PyErr_SetString(PyExc_AttributeError, "Cannot delete data threshold");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!long_Check(value)){
|
||||
PyErr_SetString(PyExc_TypeError, "Data threshold must be an int");
|
||||
return -1;
|
||||
}
|
||||
|
||||
r = sd_journal_set_data_threshold(self->j, (size_t) long_AsLong(value));
|
||||
return set_error(r, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(closed__doc__,
|
||||
"True iff journal is closed");
|
||||
static PyObject* Reader_get_closed(Reader *self, void *closure) {
|
||||
return PyBool_FromLong(self->j == NULL);
|
||||
}
|
||||
|
||||
|
||||
static PyGetSetDef Reader_getsetters[] = {
|
||||
{(char*) "data_threshold",
|
||||
{ (char*) "data_threshold",
|
||||
(getter) Reader_get_data_threshold,
|
||||
(setter) Reader_set_data_threshold,
|
||||
(char*) data_threshold__doc__,
|
||||
NULL},
|
||||
{(char*) "closed",
|
||||
NULL },
|
||||
{ (char*) "closed",
|
||||
(getter) Reader_get_closed,
|
||||
NULL,
|
||||
(char*) closed__doc__,
|
||||
NULL},
|
||||
NULL },
|
||||
{} /* Sentinel */
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user