A simple slack notification tool to alert you when scripts finish running.
Project description
slack-notif
A simple Python package to send well-structured Slack notifications for your scripts, including success/error status, execution time, and custom content.
Installation
pip install slack-notif
Usage
First, you'll need a Slack bot token. Create one at https://api.slack.com/apps.
Basic Usage
from slack_notif import NotificationManager
# Initialize the notification manager
notif = NotificationManager(
token="xoxb-your-token",
channel="#your-channel"
)
# Use as a decorator
@notif.notify
def my_function():
# Your code here
pass
# Add extra content to notifications
@notif.notify(extra_content={"Environment": "Production", "Version": "1.0.0"})
def another_function():
# Your code here
pass
# Or send notifications manually
notif.send_notification(
status="success",
message="Data processing complete",
duration=42.5, # seconds
extra_content={"Rows Processed": 1000}
)
Features
- ✨ Clean, modern Slack message formatting
- ⏱️ Automatic execution time tracking
- 🎯 Success/error status with appropriate colors
- 📝 Support for custom additional content
- 🔄 Easy-to-use decorator syntax
- ⚡ Simple manual notification sending
Example Output
The notifications will include:
- A header with the script status (Success/Error)
- The main message
- Execution duration (if provided)
- Any extra content in a clean key-value format
Development
To set up for development:
pip install -e ".[dev]"
License
Not affiliated with Slack.
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file slack_notif-0.1.0.tar.gz.
File metadata
- Download URL: slack_notif-0.1.0.tar.gz
- Upload date:
- Size: 2.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
016a1b2352607ffc886c8424f55c4ca723a3bdbb662584cc5dda6e6fa0710c85
|
|
| MD5 |
d5161ad1497597526be5ae24911fc659
|
|
| BLAKE2b-256 |
0d8c8c50286c7d033e153d5f180063a68457ee64a27234351be2f736c3c839c3
|
File details
Details for the file slack_notif-0.1.0-py3-none-any.whl.
File metadata
- Download URL: slack_notif-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84f6ef42d54957261e1dc0ce0d3354d9440960dd58137f197f375da6b8bdfc47
|
|
| MD5 |
b48e6d675e882970c647920d9219f611
|
|
| BLAKE2b-256 |
58d16d25393df8b24db499ccaeef5c10153b0dd28df49bec8aef137c54e2df9a
|