ix-notifiers
A python library for sending one notification to several services at once.
Install
pip install ix-notifiers
Usage
Build a core, register the notifiers you want, then send. notify() returns True when
at least one channel accepted the notification.
from ix_notifiers import IxNotifiers
notifiers = IxNotifiers()
# Each keyword is prefixed with the name of the notifier it belongs to. The prefix is
# stripped before the notifier sees it, so `gotify_token` arrives as `token`.
notifiers.register(
"gotify",
gotify_url="https://gotify.example.com",
gotify_token="your-application-token",
gotify_default_priority=5,
)
notifiers.register("null")
notifiers.notify(title="Deploy", message="finished")
Every core holds its own registry, so two cores in one process do not see each other's notifiers. Registering a name no notifier answers to logs a warning and registers nothing.
Notifiers
Discovery is by filename: every *_notifier.py in the package is available under the
name in front of _notifier.
gotify
Posts to a Gotify server's /message endpoint.
| Parameter | Mandatory | Default | Description |
|---|---|---|---|
gotify_url |
yes | - | base URL of the Gotify server |
gotify_token |
yes | - | application token, kept out of the logs |
gotify_content_type |
no | text/markdown |
content type of the message body |
gotify_default_priority |
no | 0 |
priority for messages that carry none |
send() accepts title, message, priority and content_type. A field that is not
given is left out of the request, and content_type overrides the default for that one
message. A priority that will not convert to an integer is logged and the message is
sent without one.
null
Logs the notification at info level and reports success. Useful for a dry run.
Writing a notifier
Add a <name>_notifier.py to the package with a Notifier subclass, a params
declaration and a module-level start:
from typing import Any, ClassVar
from .notifier import Notifier
class WebhookNotifier(Notifier):
"""Posts a notification to a webhook."""
params: ClassVar[dict[str, dict[str, Any]]] = {
"url": {"mandatory": True, "type": "string"},
"secret": {"mandatory": True, "redact": True, "type": "string"},
"timeout": {"default": 10, "type": "integer"},
}
def send(self, **kwargs: Any) -> bool:
"""Sends the notification and reports whether it was accepted."""
...
start = WebhookNotifier.start
Each parameter declares a type of boolean, integer or string, and optionally
mandatory, default and redact. The base class resolves them into self.settings:
- a mandatory parameter has to be present, and a supplied
0,Falseor""counts as present - an optional parameter falls back to its
default, or toNonewhere it declares none - a value of the wrong declared type is rejected, and an integer parameter rejects a boolean
- a parameter marked
redacthas its value masked out of anything the notifier logs throughself.redact()
Logging
Every module logs to the ix-notifiers logger and attaches no handler of its own, so
the application decides where the records go.
Contributing
See CONTRIBUTING.md. Every change has to pass ruff check,
ruff format --check, pylint and the test suite at 100% statement and branch
coverage.
Metadata
Release files for ix-notifiers 2.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ix_notifiers-2.0.11.tar.gz | 11.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ix_notifiers-2.0.11-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.6 kB
Release files / ix_notifiers-2.0.11.tar.gz
| Download URL | ix_notifiers-2.0.11.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95c66121ed8642830a9959df2d8f67bc4c73ed8bd62d8f22bf7e3c8bdf391572
|
|
BLAKE2b-256 checksum How to use checksums |
03bf0d3814c6de507372a405a18ae3ac8cd66e7fc8e02d4c3366c2aa38ec4a37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.3 CPython/3.14.7 Linux/7.0.0-31-generic
|
Release files / ix_notifiers-2.0.11-py3-none-any.whl
| Download URL | ix_notifiers-2.0.11-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f98781a059492ed91fbdc8767efe0ba8e32f6689d2853b21566c87c61d71b76d
|
|
BLAKE2b-256 checksum How to use checksums |
7e48d92679561ee2f6bc5446fcb8106d2be25d408fa1af838cf3cd7528d00f66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.3.3 CPython/3.14.7 Linux/7.0.0-31-generic
|