trick17 0.0.4

Creator: bradpython12

Last updated:

0 purchases

trick17 0.0.4 Image
trick17 0.0.4 Images

Languages

Categories

Add to Cart

Description:

trick17 0.0.4

trick17



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

Table of Contents

Installation
Modules
License
Motivation

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.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.