Zbigniew Jędrzejewski-Szmek
7b732ed75d
systemd-python: update documentation for new systemd-journal group
2015-07-05 14:19:17 -04:00
Zbigniew Jędrzejewski-Szmek
67bdb044d8
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.
2015-07-05 14:19:17 -04:00
Zbigniew Jędrzejewski-Szmek
000525db3e
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.
2015-07-05 14:19:17 -04:00
Zbigniew Jędrzejewski-Szmek
cbbe787926
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.
2015-07-05 14:19:17 -04:00
Zbigniew Jędrzejewski-Szmek
0fe854e001
systemd-python: catch only ValueErrors in conversion code
...
First of all, 'try: ... except: ...' (with no exception specified) is
always a no-no, since it catches all BaseExceptions, which includes ^C
and other stuff which should almost never be caught.
Now the conversion is stricter, and only one conversion is attempted,
and only a ValueEror is caught. It seems reasonable to catch ValueErrors,
since the entries in the journal are not verified, and any erroneous
application might log a field which cannot be converted. The consumer
of events must only check if a field is an instance of bytes and can
otherwise assume that the conversion was performed correctly.
Order of arguments in Reader.__init__ has been changed to match order
in _Reader.__init__.
Conversions have been updated to work under Python 2 and 3.
2015-07-05 14:19:17 -04:00
Zbigniew Jędrzejewski-Szmek
68bdaeba7a
systemd-python: fix error check in _Reader.wait()
2015-07-05 14:19:17 -04:00
Lukas Nykryn
5ed6b60c15
systemd-python: add missing check for return of PyDict_SetItem in _reader.c
2015-07-05 14:19:17 -04:00
Zbigniew Jędrzejewski-Szmek
3223d0b21f
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.
2015-07-05 14:19:17 -04:00
Zbigniew Jędrzejewski-Szmek
4a3c9f4286
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).
2015-07-05 14:19:17 -04:00
Zbigniew Jędrzejewski-Szmek
7db007ce6c
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.
2015-07-05 14:19:17 -04:00
Zbigniew Jędrzejewski-Szmek
cedd0fd249
systemd-python: hide ChainMap import
2015-07-05 14:19:17 -04:00
Zbigniew Jędrzejewski-Szmek
8d697bfd13
systemd-python: document attributes
...
In id128 it would be better to add everything automatically, but
sphinx cannot do this right now.
2015-07-05 14:19:16 -04:00
Zbigniew Jędrzejewski-Szmek
ec05eb1aef
systemd-python: use PyModule_AddObject in id128
2015-07-05 14:19:16 -04:00
Zbigniew Jędrzejewski-Szmek
c18311bd54
systemd-python: polish the docstrings
2015-07-05 14:19:16 -04:00
Zbigniew Jędrzejewski-Szmek
2575a15b61
systemd-python: indenation and style tweaks
2015-07-05 14:19:16 -04:00
Zbigniew Jędrzejewski-Szmek
79931a5520
systemd-python: downgrade _reader.c to C89
2015-07-05 14:19:16 -04:00
Zbigniew Jędrzejewski-Szmek
b8b5706a1d
systemd-python: add casts and fix unused variable warnings in _reader
2015-07-05 14:19:16 -04:00
Zbigniew Jędrzejewski-Szmek
2d3c2201a4
systemd-python: wrap some python differences using macros
2015-07-05 14:19:16 -04:00
Zbigniew Jędrzejewski-Szmek
544fbf3b3a
systemd-python: introduce error setting helper
2015-07-05 14:19:16 -04:00
Steven Hiscocks
31d2aff90e
systemd-python: Added doc string for Journal
2015-07-05 14:19:16 -04:00
Steven Hiscocks
7df62d3a00
systemd-python: Journal convert_unicode exception handling change
...
Rather than catch all, is now limited to UnicodeDecodeError
2015-07-05 14:19:16 -04:00
Steven Hiscocks
d21d05648d
systemd-python: add Journal method to add MESSAGE_ID match
2015-07-05 14:19:16 -04:00
Steven Hiscocks
82ff2498de
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
2015-07-05 14:19:16 -04:00
Steven Hiscocks
3813a8ab26
systemd-python: update Journal python docstrings
2015-07-05 14:19:16 -04:00
Steven Hiscocks
8d5a8d3654
systemd-python: tidy up import names in journal
2015-07-05 14:19:16 -04:00
Steven Hiscocks
2f5a35a755
systemd-python: Journal this_boot/machine now accepts ID
2015-07-05 14:19:15 -04:00
Steven Hiscocks
9d405a0928
systemd-python: remove unneeded ifdef for query_unique
2015-07-05 14:19:15 -04:00
Steven Hiscocks
445332cb69
systemd-python: _reader now takes unix timestamp in seconds
2015-07-05 14:19:15 -04:00
Steven Hiscocks
029ac59922
systemd-python: Update _reader docstrings
2015-07-05 14:19:15 -04:00
Steven Hiscocks
097bcda6ce
systemd-python: _reader add_match takes single string
...
python code now takes care of multiple matches
2015-07-05 14:19:15 -04:00
Steven Hiscocks
7258e1a44a
systemd-python: correct data_threshold error return value
2015-07-05 14:19:15 -04:00
Steven Hiscocks
ab67680240
systemd-python: updated _reader header to standard license
2015-07-05 14:19:15 -04:00
Steven Hiscocks
716351a180
systemd-python: Moved _reader datetime usage to python
2015-07-05 14:19:15 -04:00
Steven Hiscocks
c5ba02c0a8
systemd-python: Tidy up _reader error handling
2015-07-05 14:19:15 -04:00
Steven Hiscocks
461dbcafe9
systemd-python: some python3 and bug fixes
2015-07-05 14:19:15 -04:00
Steven Hiscocks
55c89e4680
systemd-python: implement this_boot/this_machine in Python
2015-07-05 14:19:15 -04:00
Steven Hiscocks
87531b51f5
systemd-python: Journal log_level moved to python
2015-07-05 14:19:15 -04:00
Zbigniew Jędrzejewski-Szmek
108e4de1e4
sphinx: document Journal class too
2015-07-05 14:19:15 -04:00
Steven Hiscocks
7d270338de
systemd-python: move default call dicts from C to python
2015-07-05 14:19:14 -04:00
Steven Hiscocks
98da3b4ec4
systemd-python: MESSAGE_ID as UUID for Journal
2015-07-05 14:19:14 -04:00
Steven Hiscocks
5ec357b071
systemd-python: moved PyRun_String to journal.py code
2015-07-05 14:19:14 -04:00
Steven Hiscocks
3503342886
systemd-python: add Journal class for reading journal
2015-07-05 14:19:14 -04:00
Zbigniew Jędrzejewski-Szmek
0c023a2c03
python: build html docs using sphinx
...
Build instructions:
make
make DESTIDIR=/tmp/... install
make DESTIDIR=/tmp/... sphinx-html sphinx-man sphinx-epub ...
2015-07-05 14:19:14 -04:00
Zbigniew Jędrzejewski-Szmek
d6cd30aa2e
python: utilize uuid.UUID in logging
2015-07-05 14:19:14 -04:00
Zbigniew Jędrzejewski-Szmek
37f8da3363
python: add systemd.id128 module
...
uuid.UUIDs are utilized to hold UUID values.
2015-07-05 14:19:14 -04:00
Marti Raudsepp
603876167a
python: add journal backend for the logging framework
...
Supports Python versions 2.6 through 3.3 (tested on 2.7 and 3.2).
See JournalHandler docstring for usage details.
[zj: - use send() instead of using sendv() directly
- do exception handling like in the logging module
- bumped min version to python2.6, since the module
does not work with python2.5 anyway ]
2015-07-05 14:19:14 -04:00
Zbigniew Jędrzejewski-Szmek
4b22c01793
systemd-python: fix nesting of #ifs and #pragmas
2015-07-05 14:19:14 -04:00
Lennart Poettering
059247a62f
python: make gcc shut up
2015-07-05 14:19:14 -04:00
Lennart Poettering
da42130ac5
python: fix error handling, and allocate argument array on the stack
2015-07-05 14:19:14 -04:00
Lennart Poettering
3bb03b4e4d
python: reindent to follow coding style
2015-07-05 14:19:14 -04:00