Commit graph

164 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
276f137b57 id128: add SD_MESSAGE_TRUNCATED_CORE from upcoming systemd-232 2016-10-17 04:16:43 -04:00
Zbigniew Jędrzejewski-Szmek
5a5063bac0 journal: allow stream() to be used without any arguments
It's fairly easy to provide a reasonable default for the first argument.
Let's do that.

Also, the documentation was misleading, suggesting that the function itself
can be passed as file parameter to print(). Use a different name for the
temporary variable to clarify that.
2016-10-17 04:10:06 -04:00
Zbigniew Jędrzejewski-Szmek
52d9f51b9b journal: bump default log level for stream() to INFO
By default debug messages are ignored, and INFO should be used for
"normal" messages.
2016-10-17 04:02:50 -04:00
Zbigniew Jędrzejewski-Szmek
8024fc6171 _reader: use proper ifdef guard for sd_j_open_files_fd 2016-09-22 20:57:12 -04:00
Zbigniew Jędrzejewski-Szmek
35a5b281ad tests: add workaround for pre-232 system returning EINVAL on some flags 2016-09-22 20:44:25 -04:00
Zbigniew Jędrzejewski-Szmek
b9767792b9 docs: fix sphinx format warning
build/lib.linux-x86_64-3.5/systemd/journal.py:docstring of systemd.journal.stream:15: WARNING: Literal block expected; none found.
2016-09-22 09:52:58 -04:00
Zbigniew Jędrzejewski-Szmek
177ac6d894 tests: skip fdstore tests if not implemented
Should fix #12.
2016-09-22 07:49:07 -04:00
Zbigniew Jędrzejewski-Szmek
d713eacb7e Store id128-constants.h in the repository
Instead of generating the list of message ids anew during every build,
the file is generated manually and committed into the
repository. Also, the list of defines is stored in id128-defines.h,
also kept in the repository. Both files should only grow.

This should make build easier. But it also fixes a problem with
systemd, which occasionally drops message definitions. We will keep
them forever, so it should be safe to rely on the presence of message
definitions which systemd does not use anymore.

Fixes #23.
2016-09-21 20:16:37 -04:00
Zbigniew Jędrzejewski-Szmek
9e0d797ba7 journal: convert seek_realtime argument to microseconds
This somewhat breaks backwards compatibility, but not for the
previously documented arguments: floats are now interpreted
differently, but ints and datetime.datetime objects are interpreted
the same as before. But the documentation clearly stated that only
ints and datetime.datetime objects were allowed.

This makes seek_realtime match seek_monotonic and other functions
which take time and follows the principle of least surprise.

Fixes #21.
2016-09-21 20:16:37 -04:00
Zbigniew Jędrzejewski-Szmek
5211952348 tests: use a context manager, skip new functions if missing 2016-09-21 15:32:58 -04:00
Zbigniew Jędrzejewski-Szmek
02b9432e73 reader: add SD_JOURNAL_OS_ROOT and rework flag passing
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).
2016-09-21 15:32:58 -04:00
Zbigniew Jędrzejewski-Szmek
89badf50b7 journal: add support for sd_journal_open_files_fd 2016-09-21 15:32:58 -04:00
Zbigniew Jędrzejewski-Szmek
ee9ab0bd65 journal: make sd_journal_enumerate return text strings
Those are field names and they should always be ASCII, and converting
them to str automatically makes the answer more useful.
2016-09-21 15:32:58 -04:00
Zbigniew Jędrzejewski-Szmek
dadcd3d723 journal: allow sd_journal_open_directory_fd to be used 2016-09-21 15:32:58 -04:00
Zbigniew Jędrzejewski-Szmek
42f627b302 Reformat documentation to be more PEP257-compliant
Wrapping the sources to ~80 columns means that the formatted output is
annoying to read. Rewrap to ~74 columns in the output.

Also remove some obsolete descritions of journal permissions and refer
to journalctl(1) instead.

Add some missing docstrings.
2016-09-20 09:38:36 -04:00
Zbigniew Jędrzejewski-Szmek
814cdb9d6a tests: check enumerate_fields, has_runtime_fiels, has_persistent_files 2016-09-20 09:38:18 -04:00
Zbigniew Jędrzejewski-Szmek
36a384a683 journal: add wrappers for sd_has_*_files 2016-09-20 09:38:14 -04:00
Zbigniew Jędrzejewski-Szmek
819ea77d1b journal: add wrapper for sd_journal_enumerate 2016-09-20 09:38:10 -04:00
Zbigniew Jędrzejewski-Szmek
ffba3a2ff8 journal: check errors properly in query_unique 2016-09-20 09:38:03 -04:00
Michael Biebl
4c6072f61b Fix typo (#26) 2016-07-16 11:20:52 -04:00
Ville Skyttä
4c5e850b49 Use log.warning instead of deprecated log.warn in example code 2016-05-21 08:50:13 +03:00
Ville Skyttä
947f782886 Spelling fixes 2016-05-21 08:47:00 +03:00
Mike Gilbert
87a9d64550 test_daemon: Define a default value for SO_PASSCRED
The socket module seems to be missing this in python2.7.
2016-01-20 19:08:02 -05:00
Michael Herold
3d046016c4 Fixes Reader.seek_monotonic(datetime.timedelta) 2015-12-10 00:18:01 +01:00
Zbigniew Jędrzejewski-Szmek
c8749e7fbc reader: avoid gcc warning
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.
2015-12-02 20:44:15 -05:00
Zbigniew Jędrzejewski-Szmek
8ccd64789a tests: mirror is-systemd-running test from systemd 2015-10-28 10:02:53 -04:00
Zbigniew Jędrzejewski-Szmek
f83f19b3bd Python2 does not have ConnectionError 2015-10-27 00:07:18 -04:00
Zbigniew Jędrzejewski-Szmek
a947f32b31 tests: add tests for notify() 2015-10-26 23:38:58 -04:00
Zbigniew Jędrzejewski-Szmek
6baa4b417b daemon: wrap sd_pid_notify[_with_pids]
Closes #8.
2015-10-26 22:51:27 -04:00
Zbigniew Jędrzejewski-Szmek
035700c2b5 Merge branch 'tests' 2015-10-25 16:51:04 -04:00
Zbigniew Jędrzejewski-Szmek
1d8f5f26df tests: work around bug in sd_is_mq
The fix was committed in v226-362-g0260d1d542.
2015-10-25 16:50:59 -04:00
Zbigniew Jędrzejewski-Szmek
4be2fc75bf Do not assume specific output from the journal
While we *usually* get those messages from udev, in many tests environments
this will not be true, so just do not try to check the output at all.
2015-10-25 12:23:29 -04:00
Zbigniew Jędrzejewski-Szmek
173c2a89b2 tests: add simplistic tests for Reader matches
It would be nice to run those tests against fake journal files
with the right content to actually test the matches. But those
tests are still useful because they test that the interface
works as expected.
2015-09-16 12:43:06 +02:00
Zbigniew Jędrzejewski-Szmek
4f5aa7b54a journal: allow numbers in field identifiers 2015-09-17 11:53:45 +02:00
Zbigniew Jędrzejewski-Szmek
bbbc6e8a92 tests: add tests for Reader initialization 2015-09-17 11:53:45 +02:00
Zbigniew Jędrzejewski-Szmek
008aac74d7 journal: reindent to 4 spaces 2015-09-17 11:53:45 +02:00
Zbigniew Jędrzejewski-Szmek
5bf468dca1 tests: start adding tests for JournalHandler 2015-09-17 11:53:45 +02:00
Zbigniew Jędrzejewski-Szmek
5f36e8647a Normalize some strange indentation 2015-09-08 10:36:16 +02:00
Zbigniew Jędrzejewski-Szmek
085db21e5e tests: add more tests for socket functions 2015-09-06 18:54:55 +02:00
Zbigniew Jędrzejewski-Szmek
e6b305b41a tests: adapt to python2.7 output again 2015-09-05 14:23:20 +02:00
Zbigniew Jędrzejewski-Szmek
0cf0cf7e42 tests: daemon.booted 2015-09-05 14:18:32 +02:00
Zbigniew Jędrzejewski-Szmek
2e115f3c4f tests: daemon.listen_fds 2015-09-05 14:18:23 +02:00
Zbigniew Jędrzejewski-Szmek
cc5f218a50 tests: enable doctests in the sources
Unfortunately the "standard" way to access the names in the
defined module does not work. I find it nicer to explicitly import,
e.g. from systemd import journal, because then the examples
correspond more closely to what a user would use. The only
exception is made for JournalHandler, because journal.JournalHandler
is a tad to long.
2015-09-05 13:09:43 +02:00
Evgeny Vereshchagin
b71b8b64eb Fix booted() doc 2015-09-04 18:30:10 +02:00
Zbigniew Jędrzejewski-Szmek
f83dea9f8d Add compatibility with systemd < 205 2015-09-04 17:16:28 +02:00
Zbigniew Jędrzejewski-Szmek
a93828172f tests: add first test
This is based on the code in https://github.com/systemd/python-systemd/pull/4
by Jacek Konieczny <j.konieczny@eggsoft.pl>.
2015-08-07 11:49:56 -04:00
Zbigniew Jędrzejewski-Szmek
d2bc513440 tree-wide: systemd→python-systemd in headers 2015-08-07 11:49:56 -04:00
Jacek Konieczny
71d82616a8 Fix daemon.is_fifo and .is_mq under Python 3
The 'path' parameter was not properly converted from Unicode
and the functions would always fail when a path was provided.

https://github.com/systemd/python-systemd/pull/4
2015-08-07 11:49:42 -04:00
Zbigniew Jędrzejewski-Szmek
1ad7f56b90 Move docs to top level and include in manifest 2015-07-08 13:45:03 -04:00
Zbigniew Jędrzejewski-Szmek
410f054ddf Update LICENSE file and classifiers
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.
2015-07-05 20:16:51 -04:00