A Python tool for sending Slack notifications on job completion.
Project description
SlackNotifPy
slacknotifpy
is a Python CLI tool that sends notifications to a specified Slack channel on job completion. This can be especially useful for tracking automated job results, such as success or failure, directly in Slack.
Features
- Runs a Python script and sends a Slack notification upon completion.
- Customizable success and failure messages.
- Simple configuration for Slack tokens and channel IDs.
Installation
Install slacknotifpy
from PyPI:
pip install slacknotifpy
Configuration
To use slacknotifpy
, you need to configure it with your Slack token and channel ID. These settings will be saved in a .slacknotif_config
file.
- Run the following command to set up the configuration:
slacknotif config setconfig <job_script.py>
- Follow the prompts to enter:
- Slack Token
- Slack Channel ID
- Custom success and failure messages (optional)
You can find the Slack token and channel ID in your Slack app settings.
Custom Messages
To update the success and failure messages for a project, use:
slacknotif config setmessages <job_script.py>
Usage
After configuring slacknotifpy
, you can use it to run scripts and send notifications:
slacknotif run <script_path> [job_name]
script_path
: The path to the Python script you want to run.job_name
(optional): A name for the job, used in the Slack message. Defaults to the script filename.
Example:
slacknotif run my_script.py "Data Processing Job"
Example Slack Notification Messages
- Success: "Data Processing Job completed successfully"
- Failure: "Data Processing Job failed"
You can customize these messages using {job_name}
as a placeholder in the config.
Command Reference
- Configure Slack:
slacknotif config setconfig <job_script.py>
- Set Custom Messages:
slacknotif config setmessages <job_script.py>
- Run Script and Notify:
slacknotif run <script_path> [job_name]
License
This project is licensed under the MIT License.
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
File details
Details for the file slacknotifpy-1.0.4.tar.gz
.
File metadata
- Download URL: slacknotifpy-1.0.4.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | be078e9f21fc972f3ed33e995c3b1c85fc666c3c2b0eacabc92504d3cdc7b00c |
|
MD5 | c333e30b67c84d11eb549ec49c5e5264 |
|
BLAKE2b-256 | 16dfeb800aa2a510ee9b6c4b1218883949ac264974362b3d30b2c143ec9a02ff |
File details
Details for the file slacknotifpy-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: slacknotifpy-1.0.4-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9550f76b42eb013d74a6c08923c4bfd8da09060d833ef839651849dbf4ae974d |
|
MD5 | 0f4ff12cbbcd574267c102f1a6436f53 |
|
BLAKE2b-256 | 1ae8d5616e3c5a25a6bbb179a683bd9d82e874522639f40f65c3f4b1271f56ae |