Python systemd wrapper
Project description
Python systemd wrapper using Cython
Installation
You should install systemd headers
For debian users:
apt-get install build-essential \
libsystemd-journal-dev \
libsystemd-daemon-dev \
libsystemd-dev
For CentOS/RHEL
yum install gcc systemd-devel
And install it from pypi
pip install systemd
Usage examples
Systemd daemon notification
from systemd.daemon import notify, Notification
# Send READY=1
notify(Notification.READY)
# Send status
notify(Notification.STATUS, "I'm fine.")
# Send stopping
notify(Notification.STOPPING)
Write message into Systemd journal
from systemd import journal
journal.write("Hello Lennart")
# Or send structured data
journal.send(
message="Hello Lennart",
priority=journal.Priority.INFO,
some_field='some value',
)
Or add logging handler to python logger
from systemd import journal
import logging
import uuid
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger()
logger.addHandler(journal.JournaldLogHandler())
try:
log.info("Trying to do something")
raise Exception('foo')
except:
logger.exception("Test Exception %s", 1)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
systemd-0.12.0.tar.gz
(168.9 kB
view details)
File details
Details for the file systemd-0.12.0.tar.gz
.
File metadata
- Download URL: systemd-0.12.0.tar.gz
- Upload date:
- Size: 168.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf60af358e2a849e82691ec0b9a4a4dfbeba0412598ecdb07b91ff57118bf275 |
|
MD5 | 3fa86a5437de8f51550e949a546f2fee |
|
BLAKE2b-256 | 61b07af5b9e068503b88c1127975d28ae90062a6afe6ef3e5a85c9be929c0f60 |