summaryrefslogtreecommitdiff
path: root/systemd/_reader.c
Commit message (Collapse)AuthorAgeFilesLines
* _daemon,_reader: return ENOSYS instead of NotImplementedZbigniew Jędrzejewski-Szmek2016-12-151-3/+3
| | | | | | | | | In _reader we were raising OSError(errno=ENOSYS), but in _dameon we were raising NotImplementedError. Let's always use ENOSYS. Also, make the messages in _reader more specific. Fixes #33.
* _reader: use proper ifdef guard for sd_j_open_files_fdZbigniew Jędrzejewski-Szmek2016-09-221-3/+7
|
* reader: add SD_JOURNAL_OS_ROOT and rework flag passingZbigniew Jędrzejewski-Szmek2016-09-211-13/+16
| | | | | | | | | | | | | | | | | Let's pass any flags through to the journal functions without checking validity. Those functions do their own checking, so there's no need to second-guess. The semantics for _Reader(flags=0) are a bit changed: before, this would be transformed into sd_journal_open(SD_J_LOCAL_ONLY). Now, this results in sd_journal_open(0). Previous behaviour should be achieved by not specifying the flags at all. This change is necessary, because previously it was not possible to pass flags=0 to sd_journal_open(0), i.e. it was not possible to "merge" journals through the Python interface. Similarly, Reader(flags=0) now means to open all journals, and Reader(flags=None) is the same as Reader(flags=LOCAL_ONLY).
* journal: add support for sd_journal_open_files_fdZbigniew Jędrzejewski-Szmek2016-09-211-15/+81
|
* journal: make sd_journal_enumerate return text stringsZbigniew Jędrzejewski-Szmek2016-09-211-1/+1
| | | | | Those are field names and they should always be ASCII, and converting them to str automatically makes the answer more useful.
* journal: allow sd_journal_open_directory_fd to be usedZbigniew Jędrzejewski-Szmek2016-09-211-51/+106
|
* journal: add wrappers for sd_has_*_filesZbigniew Jędrzejewski-Szmek2016-09-201-31/+77
|
* journal: add wrapper for sd_journal_enumerateZbigniew Jędrzejewski-Szmek2016-09-201-31/+79
|
* journal: check errors properly in query_uniqueZbigniew Jędrzejewski-Szmek2016-09-201-5/+20
|
* Fix typo (#26)Michael Biebl2016-07-161-1/+1
|
* reader: avoid gcc warningZbigniew Jędrzejewski-Szmek2015-12-021-1/+1
| | | | | | | gcc warns that r might be uninitialized, because it doesn't know that r will be initialized in the 'if' statement. Initialize the variable to avoid the warning.
* Add compatibility with systemd < 205Zbigniew Jędrzejewski-Szmek2015-09-041-2/+13
|
* tree-wide: systemd→python-systemd in headersZbigniew Jędrzejewski-Szmek2015-08-071-3/+3
|
* Update LICENSE file and classifiersZbigniew Jędrzejewski-Szmek2015-07-051-1/+0
| | | | | | The license was originally MIT, but when this module became part of systemd, it was changed to LGPLv2+. All files had correct headers, so only the LICENSE file needs updating. Take the opportunity to add classifiers to setup.py.
* build-sys: update setup.py to build everythingZbigniew Jędrzejewski-Szmek2015-07-051-5/+6
|
* python-systemd: avoid hitting assert in __exit__Dave Reisner2015-07-051-1/+1
| | | | | Reader_close() asserts that 'args' is always NULL, but the __exit__ function forwards a non-NULL args.
* Always prefer our headers to system headersZbigniew Jędrzejewski-Szmek2015-07-051-1/+1
| | | | | | In practice this shouldn't make much difference, but sometimes our headers might be newer, and we want to test them.
* systemd-python: fix failing assertZbigniew Jędrzejewski-Szmek2015-07-051-1/+0
| | | | | A parameter which was always null before, now get's set to the module.
* python: reindent _reader.cLennart Poettering2015-07-051-582/+577
| | | | | All files should follow our coding style, and that means 8ch indenting. Let's correct that.
* macro: introduce nice macro for disabling -Wmissing-prototypes warnigsLennart Poettering2015-07-051-3/+2
|
* systemd-python: fix setting of exception codesZbigniew Jędrzejewski-Szmek2015-07-051-35/+28
| | | | | | | The return value of 0 would be treated as failure by mistake, resulting in " SystemError: error return without exception set". The way that set_error() is used is changed to be the same everywhere.
* trivial coding style clean upsThomas Hindoe Paaboel Andersen2015-07-051-72/+36
| | | | | | | | | | | | | | - Add space between if/for and the opening parentheses - Place the opening brace on same line as the function (not for udev) From the CODING_STYLE Try to use this: void foo() { } instead of this: void foo() { }
* systemd-python: check for oom, give nicer error messagesZbigniew Jędrzejewski-Szmek2015-07-051-2/+6
|
* systemd-python: fix initialization of _Reader objectsSteven Hiscocks2015-07-051-0/+9
| | | | https://bugzilla.redhat.com/show_bug.cgi?id=995575
* systemd-python: fix gcc warningZbigniew Jędrzejewski-Szmek2015-07-051-2/+2
| | | | | | | src/python-systemd/_reader.c: In function Reader_get_catalog: src/python-systemd/_reader.c:912:53: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] assert(mid_len > l); ^
* systemd-python: use modern CZbigniew Jędrzejewski-Szmek2015-07-051-39/+10
|
* systemd-python: add support for sd_j_open_filesZbigniew Jędrzejewski-Szmek2015-07-051-13/+71
| | | | Also export missing flags.
* journal: add ability to filter by current userZbigniew Jędrzejewski-Szmek2015-07-051-0/+1
| | | | | | | | | | | | | | | | This is the just the library part. SD_JOURNAL_CURRENT_USER flags is added to sd_j_open(), to open files from current user. SD_JOURNAL_SYSTEM_ONLY is renamed to SD_JOURNAL_SYSTEM, and changed to mean to (also) open system files. This way various flags can be combined, which gives them nicer semantics, especially if other ones are added later. Backwards compatibility is kept, because SD_JOURNAL_SYSTEM_ONLY is equivalent to SD_JOURNAL_SYSTEM if used alone, and before there we no other flags.
* systemd-python: wrap sd_login_monitorZbigniew Jędrzejewski-Szmek2015-07-051-20/+2
|
* systemd-python: add wrappers for easy functions in sd-loginZbigniew Jędrzejewski-Szmek2015-07-051-13/+1
| | | | sd_get_uids, sd_get_seats, sd_get_sessions, and sd_get_machine_names.
* systemd-python: add __version__ stringsZbigniew Jędrzejewski-Szmek2015-07-051-1/+3
|
* systemd-python: wrap sd_journal_add_conjunctionZbigniew Jędrzejewski-Szmek2015-07-051-1/+22
|
* move _cleanup_ attribute in front of the typeHarald Hoyer2015-07-051-5/+5
| | | | http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
* python-systemd: Reader return special fields and _Reader changesSteven Hiscocks2015-07-051-63/+28
| | | | | | | | | | | | | | | | | | | | | | | | Changes to _Reader make it match closer to C API, by removing `get_next` and `get_previous`. A `get_all` method added, which returns dictionary of fields using C API SD_JOURNAL_FOREACH_DATA macro, which can be used in conjunction with `next`. _Reader `get`, `next`, `get_{realtime,monotonic,cursor}` and new `previous` methods are made private. This is so the traversal and getting of journal fields can be made transparent in the python interface. Reader now solely implements `get_next` and `get_previous`, returning a standard dictionary (future: other mapping types?) with all standard and special fields through the converters. This makes the output the same as journalctl json/export format output. Iterator methods also moved to Reader, as they do not function as intend with changes to _Reader. These changes also mean that more optimised journal interfaces can be made more easily from _Reader, by avoiding getting of unrequired fields by using the `_get` method, and avoiding field conversions.
* systemd-python: export new sd_journal_{process,get_events,get_timeout}Zbigniew Jędrzejewski-Szmek2015-07-051-4/+103
| | | | | | | get_timeout_ms is added as a convenience function, since it is abysmally hard to call clock_gettime() in Python versions lower than 3.3. And even for Python 3.3 users it saves a few lines.
* systemd-python: fix formatting in docstringZbigniew Jędrzejewski-Szmek2015-07-051-5/+6
|
* Use initalization instead of explicit zeroingZbigniew Jędrzejewski-Szmek2015-07-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | Before, we would initialize many fields twice: first by filling the structure with zeros, and then a second time with the real values. We can let the compiler do the job for us, avoiding one copy. A downside of this patch is that text gets slightly bigger. This is because all zero() calls are effectively inlined: $ size build/.libs/systemd text data bss dec hex filename before 897737 107300 2560 1007597 f5fed build/.libs/systemd after 897873 107300 2560 1007733 f6075 build/.libs/systemd … actually less than 1‰. A few asserts that the parameter is not null had to be removed. I don't think this changes much, because first, it is quite unlikely for the assert to fail, and second, an immediate SEGV is almost as good as an assert.
* systemd-python: allow retrieval of single fieldsZbigniew Jędrzejewski-Szmek2015-07-051-18/+91
| | | | | This can give huge efficiency gains, e.g. if only MESSAGE is required and all other fields can be ignored.
* systemd-python: split out realtime and monotonic into separate functionsZbigniew Jędrzejewski-Szmek2015-07-051-65/+99
| | | | | | | | | | | 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.
* systemd-python: implement _Reader.test_cursorZbigniew Jędrzejewski-Szmek2015-07-051-20/+46
| | | | | | 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.
* systemd-python: cleanup up usec_t handlingZbigniew Jędrzejewski-Szmek2015-07-051-27/+12
| | | | | | | | | 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.
* systemd-python: export sd_journal_get_usageZbigniew Jędrzejewski-Szmek2015-07-051-6/+29
|
* systemd-python: small cleanupsZbigniew Jędrzejewski-Szmek2015-07-051-9/+29
| | | | | | - separate methods with two empty lines for clarity - avoid malloc(0) by specyfing private data size as -1 - add method name in error messages
* systemd-python: add journal.get_catalog()Zbigniew Jędrzejewski-Szmek2015-07-051-7/+46
| | | | | This one wraps sd_journal_get_catalog_from_message_id. Thanks to Python namespacing, we can stick to a shorter name.
* systemd-python: add _Reader.get_catalog()Zbigniew Jędrzejewski-Szmek2015-07-051-0/+24
| | | | This one wraps sd_journaal_get_catalog.
* systemd-python: add _Reader.closed attributeZbigniew Jędrzejewski-Szmek2015-07-051-2/+14
| | | | This should make the file interface of _Reader complete.
* systemd-python: allow Reader to be used as a context managerZbigniew Jędrzejewski-Szmek2015-07-051-0/+32
|
* systemd-python: add systemd.daemon wrapping sd-daemonZbigniew Jędrzejewski-Szmek2015-07-051-17/+0
| | | | | | | | | 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.
* systemd-python: fix segfault on double closeZbigniew Jędrzejewski-Szmek2015-07-051-0/+1
|
* systemd-python: fix typosZbigniew Jędrzejewski-Szmek2015-07-051-2/+2
|