post_json (utils/notify.py)

mate · shared/utils/notify.py · python · Apache-2.0
email

Resilient notification primitives for HTTP JSON POST and SMTP email that never raise exceptions, returning success flags for scheduler safety.

# Source: https://github.com/antiv/mate | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
# Provided via justclaw.it.com; keep this notice with the code.
"""
Outbound notification primitives shared by triggers and alert rules.

Both features need "POST this JSON" and "send this email", and the trigger
runner grew its own copies first. These are the single implementation: they
never raise and report success as a flag, so a scheduler thread cannot be taken
down by a dead endpoint. Callers that must surface failure as an exception —
the trigger runner does, since it records the result from a raised error — wrap
them.
"""

import logging
import os
import smtplib
from email.message import EmailMessage
from typing import Any, Dict, Optional, Tuple

imp

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key