Skip to main content

Python systemd wrapper

Project description

Latest Version https://img.shields.io/pypi/wheel/systemd.svg https://img.shields.io/pypi/pyversions/systemd.svg https://img.shields.io/pypi/l/systemd.svg

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


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.11.1.tar.gz (169.0 kB view details)

Uploaded Source

File details

Details for the file systemd-0.11.1.tar.gz.

File metadata

  • Download URL: systemd-0.11.1.tar.gz
  • Upload date:
  • Size: 169.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for systemd-0.11.1.tar.gz
Algorithm Hash digest
SHA256 e9a50879ab6bf5351fd2f10913cb939be9239587800404f5b171b19b39ae5c1d
MD5 54aa9a3bc1f5eed0ba61649d2d5cb0e9
BLAKE2b-256 e1b48a549a683a5b79957b09bc9a9cfcc493abe54424c8a871088cd392b89909

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page