1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-08 11:27:32 +03:00
Commit Graph

44 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
811de196b3 systemd-python: allow retrieval of single fields
This can give huge efficiency gains, e.g. if only MESSAGE
is required and all other fields can be ignored.
2013-03-21 23:05:09 -04:00
Zbigniew Jędrzejewski-Szmek
5e8ba1a460 systemd-python: split out realtime and monotonic into separate functions
This matches the C API more closely, and also enables the
user to get just partial information, should she desire to
do so.

Functions names in error messages are modified to not include
the class name, because Python uses just the function name
into functions declared as METH_NOARGS, and error messages
were inconsistent.
2013-03-21 23:05:08 -04:00
Zbigniew Jędrzejewski-Szmek
1cdcd71be0 systemd-python: implement _Reader.test_cursor
Getting the cursor is split out from .get_next() into
.get_cursor(). This mirrors the C API more closely, and
also makes things a bit faster if the cursor is not needed.
2013-03-21 22:39:24 -04:00
Zbigniew Jędrzejewski-Szmek
806bc1cb61 systemd-python: cleanup up usec_t handling
The behaviour wrt. seconds vs. microseconds was inconsistent.
Now _Reader always uses native units (us), while Reader always
uses seconds and accepts both floats and ints. This way the
conversion is always done in the Python layer, and the lower
level API allows access to the journal API without the potentially
lossy conversion between double and uint64_t.
2013-03-21 22:39:24 -04:00
Zbigniew Jędrzejewski-Szmek
50a279f857 systemd-python: export sd_journal_get_usage 2013-03-21 22:39:24 -04:00
Zbigniew Jędrzejewski-Szmek
ab3a162c01 systemd-python: small cleanups
- separate methods with two empty lines for clarity
- avoid malloc(0) by specyfing private data size as -1
- add method name in error messages
2013-03-19 21:50:43 -04:00
Zbigniew Jędrzejewski-Szmek
2b01924cda systemd-python: add journal.get_catalog()
This one wraps sd_journal_get_catalog_from_message_id.
Thanks to Python namespacing, we can stick to a shorter name.
2013-03-19 21:50:42 -04:00
Zbigniew Jędrzejewski-Szmek
6808412dad systemd-python: add _Reader.get_catalog()
This one wraps sd_journaal_get_catalog.
2013-03-19 21:50:42 -04:00
Zbigniew Jędrzejewski-Szmek
6531dac67c systemd-python: add _Reader.closed attribute
This should make the file interface of _Reader complete.
2013-03-19 21:50:42 -04:00
Zbigniew Jędrzejewski-Szmek
85b2850ba9 systemd-python: allow Reader to be used as a context manager 2013-03-18 18:53:58 -04:00
Zbigniew Jędrzejewski-Szmek
b04c8c83e8 systemd-python: add systemd.daemon wrapping sd-daemon
Please see the documentation (e.g. pydoc3 systemd.daemon) for full
description. As usual, systemd._daemon wraps the raw interface, while
systemd.daemon provides the more pythonic API. sd_listen_fds,
sd_booted, sd_is_fifo, sd_is_socket, sd_is_socket_unix,
sd_is_socket_inet, sd_is_mq, and SD_LISTEN_FDS_START are currently
wrapped.
2013-03-15 22:55:24 -04:00
Zbigniew Jędrzejewski-Szmek
db7f1dde30 systemd-python: fix segfault on double close 2013-03-07 15:35:50 -05:00
Zbigniew Jędrzejewski-Szmek
516424a411 systemd-python: fix typos 2013-03-07 15:35:50 -05:00
Zbigniew Jędrzejewski-Szmek
0eff0f3bce systemd-python: refuse path and flags together in __init__
It's better to explictly check, instead of just documenting it.

The return value from init is changed from 1 to -1 on error.
Python seems to ignore 1 every second time. Looks like a bug
in Python, but the return value doesn't seem to be documented
anywhere, and -1 works as expected... so let's just use that.
2013-03-07 11:29:08 -05:00
Zbigniew Jędrzejewski-Szmek
f2e82cd5ad systemd-python: export sd_j_get_fd, sd_j_reliable_fd, sd_j_close
sd_journal_get_fd(j) is called j.fileno(), for compatiblity with
Python conventions for file-like objects.

More importantly, those new .seek_head() and .seek_tail() do not
call .get_next(). This is better, if one wants to skip before
retrieving an entry.
2013-03-07 00:45:56 -05:00
Zbigniew Jędrzejewski-Szmek
5c1c14b3a0 systemd-python: split .seek() into .seek_head() and .seek_tail()
This way python code follows the original interface more closely.
Also, .seek(0, journal.SEEK_END) was just to much to type.
2013-03-07 00:45:56 -05:00
Zbigniew Jędrzejewski-Szmek
6210afbcff systemd-python: fix error check in _Reader.wait() 2013-03-05 23:23:09 -05:00
Lukas Nykryn
684ecf306a systemd-python: add missing check for return of PyDict_SetItem in _reader.c 2013-03-01 16:43:57 -05:00
Zbigniew Jędrzejewski-Szmek
7f41820b07 python-systemd: rename Journal to Reader
It seems inevitable that we'll also grow a writing interface,
and then it'll be cumbersome to have a "Journal" for reading,
and a "Writer" for writing.
2013-02-28 20:04:17 -05:00
Zbigniew Jędrzejewski-Szmek
86e3d32a1d systemd-python: return both parts of sd_journal_get_monotonic_usec
In Python 3, a named tuple is used. In Python 2, a simple
tuple is used. In either case, the pair is (timestamp, bootid).
2013-02-28 20:04:17 -05:00
Zbigniew Jędrzejewski-Szmek
6a6633a16a python-systemd: check all errors and use automatic cleanup
__REALTIME_TIMESTAMP and __MONOTONIC_TIMESTAMP return ints.
It doesn't make sense to convert to string, just to convert
back to a number later on.

Also try to follow systemd rules for indentation.
2013-02-28 20:04:17 -05:00
Zbigniew Jędrzejewski-Szmek
2c07646764 systemd-python: polish the docstrings 2013-02-28 19:36:14 -05:00
Zbigniew Jędrzejewski-Szmek
33ed3769b5 systemd-python: indenation and style tweaks 2013-02-22 18:09:49 +01:00
Zbigniew Jędrzejewski-Szmek
0d92ee93dc systemd-python: downgrade _reader.c to C89 2013-02-22 16:57:45 +01:00
Zbigniew Jędrzejewski-Szmek
118bf4bad8 systemd-python: add casts and fix unused variable warnings in _reader 2013-02-22 16:57:45 +01:00
Zbigniew Jędrzejewski-Szmek
ecb6dfe117 systemd-python: wrap some python differences using macros 2013-02-22 16:57:45 +01:00
Zbigniew Jędrzejewski-Szmek
e82e4f4562 systemd-python: introduce error setting helper 2013-02-22 16:57:45 +01:00
Steven Hiscocks
6d0c634ca3 systemd-python: fix memory leak in _reader and minor bugs
iternext now checks for error from get_next, and changed a DECREF to
XDECREF rather than NULL check
2013-02-22 16:57:44 +01:00
Steven Hiscocks
c71f26eba5 systemd-python: update Journal python docstrings 2013-02-22 16:57:44 +01:00
Steven Hiscocks
b835982344 systemd-python: tidy up import names in journal 2013-02-22 16:57:44 +01:00
Steven Hiscocks
dd37d563ba systemd-python: remove unneeded ifdef for query_unique 2013-02-22 16:57:44 +01:00
Steven Hiscocks
518dc5dff5 systemd-python: _reader now takes unix timestamp in seconds 2013-02-22 16:57:44 +01:00
Steven Hiscocks
83718af6f5 systemd-python: Update _reader docstrings 2013-02-22 16:57:44 +01:00
Steven Hiscocks
5bb2b8d5e4 systemd-python: _reader add_match takes single string
python code now takes care of multiple matches
2013-02-22 16:57:44 +01:00
Steven Hiscocks
a49f4d17bf systemd-python: correct data_threshold error return value 2013-02-22 16:57:44 +01:00
Steven Hiscocks
d2dd0265b5 systemd-python: updated _reader header to standard license 2013-02-22 16:57:44 +01:00
Steven Hiscocks
7a1b9cd5e4 systemd-python: Moved _reader datetime usage to python 2013-02-22 16:57:44 +01:00
Steven Hiscocks
71766afa2d systemd-python: Tidy up _reader error handling 2013-02-22 16:57:44 +01:00
Steven Hiscocks
bf1ced5503 systemd-python: some python3 and bug fixes 2013-02-22 16:57:44 +01:00
Steven Hiscocks
6a71de70e5 systemd-python: implement this_boot/this_machine in Python 2013-02-22 16:57:43 +01:00
Steven Hiscocks
25523db4e1 systemd-python: Journal log_level moved to python 2013-02-22 16:57:43 +01:00
Steven Hiscocks
3aa8f0861c systemd-python: move default call dicts from C to python 2013-02-22 16:57:43 +01:00
Steven Hiscocks
2d0603bd97 systemd-python: moved PyRun_String to journal.py code 2013-02-22 16:57:43 +01:00
Steven Hiscocks
c4e9b5b557 systemd-python: add Journal class for reading journal 2013-02-22 16:57:43 +01:00