@@ -3,52 +3,57 @@ python-systemd
3
3
4
4
Python module for native access to the systemd facilities. Functionality
5
5
is separated into a number of modules:
6
- - systemd.journal supports sending of structured messages to the journal
6
+ - ` systemd.journal ` supports sending of structured messages to the journal
7
7
and reading journal files,
8
- - systemd.daemon wraps parts of libsystemd useful for writing daemons
8
+ - ` systemd.daemon ` wraps parts of ` libsystemd ` useful for writing daemons
9
9
and socket activation,
10
- - systemd.id128 provides functions for querying machine and boot identifiers
10
+ - ` systemd.id128 ` provides functions for querying machine and boot identifiers
11
11
and a lists of message identifiers provided by systemd,
12
- - systemd.login wraps parts of libsystemd used to query logged in users
12
+ - ` systemd.login ` wraps parts of ` libsystemd ` used to query logged in users
13
13
and available seats and machines.
14
14
15
15
Installation
16
16
============
17
17
18
18
This module should be packaged for almost all Linux distributions. Use
19
19
20
- On Fedora/RHEL/CentOS
20
+ On Fedora:
21
21
22
- dnf install python-systemd python3-systemd
22
+ dnf install python3-systemd
23
23
24
- On Debian/Ubuntu/Mint
24
+ On Debian/Ubuntu/Mint:
25
25
26
- apt-get install python-systemd python3-systemd
26
+ apt update
27
+ apt install python3-systemd
27
28
28
- On openSUSE and SLE
29
+ On openSUSE and SLE:
29
30
30
- zypper in python-systemd
31
+ zypper in python3-systemd
32
+
33
+ On Arch:
34
+
35
+ pacman -Sy python-systemd
31
36
32
37
To build from source
33
38
--------------------
34
39
35
40
On CentOS, RHEL, and Fedora with Python 2:
36
41
37
42
dnf install git python-pip gcc python-devel systemd-devel
38
- pip install git+https://github.com/systemd/python-systemd.git#egg=systemd
43
+ pip install ' git+https://github.com/systemd/python-systemd.git#egg=systemd-python'
39
44
40
45
On Fedora with Python 3:
41
46
42
47
dnf install git python3-pip gcc python3-devel systemd-devel
43
- pip3 install git+https://github.com/systemd/python-systemd.git#egg=systemd
48
+ pip3 install ' git+https://github.com/systemd/python-systemd.git#egg=systemd-python'
44
49
45
50
On Debian or Ubuntu with Python 2:
46
51
47
- apt-get install libsystemd-{journal,daemon,login,id128}-dev gcc python-dev pkg-config
52
+ apt install libsystemd-{journal,daemon,login,id128}-dev gcc python-dev pkg-config
48
53
49
54
On Debian or Ubuntu with Python 3:
50
55
51
- apt-get install libsystemd-{journal,daemon,login,id128}-dev gcc python3-dev pkg-config
56
+ apt install libsystemd-{journal,daemon,login,id128}-dev gcc python3-dev pkg-config
52
57
53
58
The project is also available on pypi as ` systemd-python ` .
54
59
@@ -62,7 +67,7 @@ Quick example:
62
67
journal.send('Hello, again, world', FIELD2='Greetings!', FIELD3='Guten tag')
63
68
journal.send('Binary message', BINARY=b'\xde\xad\xbe\xef')
64
69
65
- There is one required argument -- the message, and additional fields
70
+ There is one required argument — the message, and additional fields
66
71
can be specified as keyword arguments. Following the journald API, all
67
72
names are uppercase.
68
73
@@ -119,7 +124,12 @@ Show entries by a specific executable (`journalctl /usr/bin/vim`):
119
124
for entry in j:
120
125
print(entry['MESSAGE'])
121
126
122
- - Note: matches can be added from many different fields, for example entries from a specific process ID can be matched with the ` _PID ` field, and entries from a specific unit (ie. ` journalctl -u systemd-udevd.service ` ) can be matched with ` _SYSTEMD_UNIT ` . See all fields available at the [ systemd.journal-fields docs] ( https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html ) .
127
+ - Note: matches can be added from many different fields, for example
128
+ entries from a specific process ID can be matched with the ` _PID `
129
+ field, and entries from a specific unit (ie. `journalctl -u
130
+ systemd-udevd.service` ) can be matched with ` _ SYSTEMD_UNIT`.
131
+ See all fields available at the
132
+ [ systemd.journal-fields docs] ( https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html ) .
123
133
124
134
Show kernel ring buffer (` journalctl -k ` ):
125
135
@@ -149,13 +159,13 @@ Read entries in reverse (`journalctl _EXE=/usr/bin/vim -r`):
149
159
Notes
150
160
-----
151
161
152
- * Unlike the native C version of journald's sd_journal_send(),
153
- printf-style substitution is not supported. Perform any
154
- substitution using Python's % operator or .format() capabilities
155
- first .
156
- * A ValueError is raised if sd_journald_sendv() results in an error.
157
- This might happen if there are no arguments or one of them is
158
- invalid.
162
+ * Unlike the native C version of journald's ` sd_journal_send() ` ,
163
+ printf-style substitution is not supported. Perform any
164
+ substitution using Python's f-strings first ( or .format()
165
+ capabilities or ` % ` operator) .
166
+ * A ` ValueError ` is raised if ` sd_journald_sendv() ` results in an
167
+ error. This might happen if there are no arguments or one of them
168
+ is invalid.
159
169
160
170
A handler class for the Python logging framework is also provided:
161
171
@@ -165,16 +175,16 @@ A handler class for the Python logging framework is also provided:
165
175
logger.addHandler(journal.JournalHandler(SYSLOG_IDENTIFIER='custom_unit_name'))
166
176
logger.warning("Some message: %s", 'detail')
167
177
168
- libsystemd version compatibility
169
- -------------------------------
178
+ ` libsystemd ` version compatibility
179
+ ----------------------------------
170
180
171
- This module may be compiled against any version of libsystemd. At
181
+ This module may be compiled against any version of ` libsystemd ` . At
172
182
compilation time, any functionality that is not available in that
173
- version of systemd is disabled, and the resulting binary module will
174
- depend on symbols that were available at compilation time. This means
175
- that the resulting binary module is compatible with that or any later
176
- version of libsystemd. To obtain maximum possible functionality, this
177
- module must be compile against suitably recent libsystemd.
183
+ version is disabled, and the resulting binary module will depend on
184
+ symbols that were available at compilation time. This means that the
185
+ resulting binary module is compatible with that or any later version
186
+ of ` libsystemd ` . To obtain maximum possible functionality, this module
187
+ must be compile against suitably recent libsystemd.
178
188
179
189
Documentation
180
190
=============
0 commit comments