script-reporter 🚀
A lightweight, zero-dependency Python status reporter designed for automation scripts and cron jobs. Easily report execution progress, stages, and results to Console, Discord, and Telegram.
✨ Key Features
- Zero External Dependencies: Uses Python standard library only (
urllib). - Multi-Channel: Simultaneous reporting to Console, Discord (Webhooks), and Telegram (Bot API).
- Stage Tracking: Monitor exactly where your script is (e.g.,
SETUP->PROCESSING->COMPLETE). - Error Transparency: Automatically attaches tracebacks on failure.
- Duration Tracking: Automatically calculates and reports execution time.
- CI/CD & Cron Friendly: Standardized JSON output for logs makes it easy for other tools to parse.
📦 Installation
pip install script-reporter
🚀 Quick Start
1. Simple Usage (Auto-reporitng)
Set simple environment variables to enable channels:
REPORTER_DISCORD_WEBHOOK: Discord Webhook URLREPORTER_TELEGRAM_TOKEN&REPORTER_TELEGRAM_CHAT_ID: Telegram Bot Token and Chat ID
from script_reporter import ScriptReporter
import traceback
# Initialize with a title (auto-detects Discord/Telegram from Env)
sr = ScriptReporter("My Automation Task")
try:
# 1. Start a stage
sr.stage("DATA_FETCH")
# ... your logic ...
# 2. Update stage as you progress
sr.stage("PROCESSING")
# ... your logic ...
# 3. Report success with optional detail dictionary
sr.success({"items_processed": 100, "status": "all_good"})
except Exception:
# 4. Report failure with traceback
sr.fail(traceback.format_exc())
2. Manual Configuration
Explicitly control adapters without environment variables:
from script_reporter import ScriptReporter, ConsoleAdapter, DiscordAdapter, TelegramAdapter
adapters = [
ConsoleAdapter(),
DiscordAdapter(webhook_url="https://discord.com/api/webhooks/..."),
TelegramAdapter(token="BOT_TOKEN", chat_id="CHAT_ID")
]
sr = ScriptReporter("Manual Config Task", adapters=adapters)
sr.success({"msg": "Hello from code!"})
📊 JSON Log Format
ConsoleAdapter prints a machine-readable JSON line starting with __RESULT__:
__RESULT__ {"title": "My Task", "host": "server-01", "stage": "COMPLETE", "status": "SUCCESS", "duration": "1m 30s", "detail": {"processed": 5}}
🛠 Advanced Concepts
- Stages: Use
sr.stage("NAME")to track progress. Ifsr.fail()is called, it identifies the last successful stage. - Duration: Tracks time from
ScriptReporter()initialization tosuccess()/fail()call. - Discord Rich Embeds:
DiscordAdapterautomatically formats details and errors into beautiful rich embeds.
📄 License
MIT License. See LICENSE for more details.
Release files for script-reporter 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| script_reporter-0.1.2.tar.gz | 6.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| script_reporter-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.6 kB
Release files / script_reporter-0.1.2.tar.gz
| Download URL | script_reporter-0.1.2.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a791ebbb532f1f1918c481014fe0645aed14d7d1a1ae700d5a50dfa42b219217
|
|
BLAKE2b-256 checksum How to use checksums |
fb8ff56ba92bbaf833f0086584cb87ae1e78211c4b535ba5c8d238832096e2f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / script_reporter-0.1.2-py3-none-any.whl
| Download URL | script_reporter-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8484088d57273be184bb05f696c5bf30b969efc96b3c02360d8c9fcaa38f6c2b
|
|
BLAKE2b-256 checksum How to use checksums |
3f20b098b044c05afeaf82e96433dbf96fe5211d7a44d239575ef867f753f551
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|