Skip to main content

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.

Release files for trick17 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for trick17 0.0.4
File Size Uploaded
trick17-0.0.4.tar.gz 9.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for trick17 0.0.4
File Interpreter ABI Platform
trick17-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 16.9 kB

Release files / trick17-0.0.4.tar.gz

Download URL trick17-0.0.4.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4ff6c139ea8cc4729bb2ffa4b65bf0f393edd7b8453746b5e948e32bd073b8c9
BLAKE2b-256 checksum
How to use checksums
b82efa685f2ebb6f39c84b6d8dd7c443073d2a2e365654fb6feea06d3f241453
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / trick17-0.0.4-py3-none-any.whl

Download URL trick17-0.0.4-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a089857b7de90d32d77f6c2b67678280ea37d319d9c92f74fa34b90593318d3e
BLAKE2b-256 checksum
How to use checksums
ae6feeee0dabe91a7de6436310c9fd7a718ff751b60250facd7b2a16511c1af6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page