trick17


Nametrick17 JSON
Version 0.0.3 PyPI version JSON
download
home_page
SummarySystemd utility functions in pure python
upload_time2023-08-22 16:47:32
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords systemd
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # trick17

[![Pre-Alpha warning](https://img.shields.io/badge/warning-Pre--Alpha%20code-red)]()

[![PyPI - Version](https://img.shields.io/pypi/v/trick17.svg)](https://pypi.org/project/trick17)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/trick17.svg)](https://pypi.org/project/trick17)

`trick17` is a pure python, lightweight package that interfaces with various [systemd](https://systemd.io) components.

-----

**Table of Contents**

- [Installation](#installation)
- [Modules](#modules)
- [License](#license)

## Installation

```console
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 iterator over (fd, name) tuples in case of socket activation,
  see [systemd.socket](https://www.freedesktop.org/software/systemd/man/systemd.socket.html)

### trick17.journal

The `trick17.journal` allows to use the systemd [Native Journal Protocol](https://systemd.io/JOURNAL_NATIVE_PROTOCOL/) via the Python [Logging facility](https://docs.python.org/3/library/logging.html).

- `JournalHandler` is a [`logging.Handler`](https://docs.python.org/3/library/logging.html#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](https://systemd.io/JOURNAL_NATIVE_PROTOCOL/#automatic-protocol-upgrading)

```python
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](https://spdx.org/licenses/MIT.html) license.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "trick17",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "systemd",
    "author": "",
    "author_email": "Stefano Miccoli <stefano.miccoli@polimi.it>",
    "download_url": "https://files.pythonhosted.org/packages/e6/e8/c0c62eed281147821daad110260d0abc3f41c672fe4b1a5dae4a076f9425/trick17-0.0.3.tar.gz",
    "platform": null,
    "description": "# trick17\n\n[![Pre-Alpha warning](https://img.shields.io/badge/warning-Pre--Alpha%20code-red)]()\n\n[![PyPI - Version](https://img.shields.io/pypi/v/trick17.svg)](https://pypi.org/project/trick17)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/trick17.svg)](https://pypi.org/project/trick17)\n\n`trick17` is a pure python, lightweight package that interfaces with various [systemd](https://systemd.io) components.\n\n-----\n\n**Table of Contents**\n\n- [Installation](#installation)\n- [Modules](#modules)\n- [License](#license)\n\n## Installation\n\n```console\npip install trick17\n```\n\n## Modules\n\n### trick17.daemon\n\n- `daemon.booted()` returns `True` if system was booted by systemd.\n- `daemon.notify(state)` sends a notification to systemd.\n- `listen_fds()` returns an iterator over (fd, name) tuples in case of socket activation,\n  see [systemd.socket](https://www.freedesktop.org/software/systemd/man/systemd.socket.html)\n\n### trick17.journal\n\nThe `trick17.journal` allows to use the systemd [Native Journal Protocol](https://systemd.io/JOURNAL_NATIVE_PROTOCOL/) via the Python [Logging facility](https://docs.python.org/3/library/logging.html).\n\n- `JournalHandler` is a [`logging.Handler`](https://docs.python.org/3/library/logging.html#logging.Handler) subclass that speaks the systemd Native Journal Protocol\n- Function `stderr_is_journal()` can be used to check if logging via `sys.stderr` should be upgraded to native logging, see [Automatic Protocol Upgrading](https://systemd.io/JOURNAL_NATIVE_PROTOCOL/#automatic-protocol-upgrading)\n\n```python\nimport logging\n\nfrom trick17 import journal\n\nif journal.stderr_is_journal():\n    handler = journal.JournalHandler()\nelse:\n    handler = logging.StreamHandler()\nroot = logging.getLogger()\nroot.addHandler(handler)\n\nlogging.error('Something happened')\n```\n\n## License\n\n`trick17` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Systemd utility functions in pure python",
    "version": "0.0.3",
    "project_urls": {
        "Documentation": "https://github.com/miccoli/trick17#readme",
        "Issues": "https://github.com/miccoli/trick17/issues",
        "Source": "https://github.com/miccoli/trick17"
    },
    "split_keywords": [
        "systemd"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "06a4bfeabcdb5d0db118ce332da3bb495040a53c086edfea55d996e6bd11b99a",
                "md5": "64b65f810b26b1b4677429b962420adb",
                "sha256": "031587d0c91921e311f8ec0bbbcac9428d533966cd682ac0499f62977126f841"
            },
            "downloads": -1,
            "filename": "trick17-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "64b65f810b26b1b4677429b962420adb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7280,
            "upload_time": "2023-08-22T16:47:30",
            "upload_time_iso_8601": "2023-08-22T16:47:30.704708Z",
            "url": "https://files.pythonhosted.org/packages/06/a4/bfeabcdb5d0db118ce332da3bb495040a53c086edfea55d996e6bd11b99a/trick17-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e6e8c0c62eed281147821daad110260d0abc3f41c672fe4b1a5dae4a076f9425",
                "md5": "27c8479eb4141fcf4418b91524e19454",
                "sha256": "d572f712ec678d4b8e68c9b9ecad74fd43035503edb13f945d04f9d360e80d2a"
            },
            "downloads": -1,
            "filename": "trick17-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "27c8479eb4141fcf4418b91524e19454",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8387,
            "upload_time": "2023-08-22T16:47:32",
            "upload_time_iso_8601": "2023-08-22T16:47:32.387942Z",
            "url": "https://files.pythonhosted.org/packages/e6/e8/c0c62eed281147821daad110260d0abc3f41c672fe4b1a5dae4a076f9425/trick17-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-22 16:47:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "miccoli",
    "github_project": "trick17#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "trick17"
}
        
Elapsed time: 0.13752s