Skip to main content

Systemd utility functions in pure python

Project description

trick17

Pre-Alpha warning

PyPI - Version PyPI - Python Version

trick17 is a pure python, lightweight package that interfaces with various systemd components.


Table of Contents

Installation

pip install trick17

Modules

trick17.daemon

  • daemon.booted() returns True if system was booted by systemd.
  • daemon.notify(state) sends a notification to systemd.
  • listen_fds() returns an list of (fd, name) tuples in case of socket activation, see systemd.socket

trick17.journal

The trick17.journal allows to use the systemd Native Journal Protocol via the Python Logging facility.

  • JournalHandler is a logging.Handler subclass that speaks the systemd Native Journal Protocol
  • Function stderr_is_journal() can be used to check if logging via sys.stderr should be upgraded to native logging, see Automatic Protocol Upgrading
import logging

from trick17 import journal

if journal.stderr_is_journal():
    handler = journal.JournalHandler()
else:
    handler = logging.StreamHandler()
root = logging.getLogger()
root.addHandler(handler)

logging.error('Something happened')

License

trick17 is distributed under the terms of the MIT license.

Motivation and alternatives

Many existing interfaces to systemd are python bindings to libsystemd, see e.g. python-systemd or cysystemd. Even if most systems running under systemd will have libsystemd already installed, a native python implementation has many advantages:

  • easy vendoring,
  • pypi availability of no-ABI, platform independent wheels, with no transitive dependencies.

This package is a partial implementation of the most used (at least by me) functions of libsystemd. Please feel free open a issue if this package is useful to you and misses a feature.

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

trick17-0.0.4.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

trick17-0.0.4-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file trick17-0.0.4.tar.gz.

File metadata

  • Download URL: trick17-0.0.4.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for trick17-0.0.4.tar.gz
Algorithm Hash digest
SHA256 4ff6c139ea8cc4729bb2ffa4b65bf0f393edd7b8453746b5e948e32bd073b8c9
MD5 433b9aa8537838ec26c7ad56c8ac5444
BLAKE2b-256 b82efa685f2ebb6f39c84b6d8dd7c443073d2a2e365654fb6feea06d3f241453

See more details on using hashes here.

File details

Details for the file trick17-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: trick17-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for trick17-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a089857b7de90d32d77f6c2b67678280ea37d319d9c92f74fa34b90593318d3e
MD5 dfb5881e8308a7452c7b6a3623ef4f79
BLAKE2b-256 ae6feeee0dabe91a7de6436310c9fd7a718ff751b60250facd7b2a16511c1af6

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