Skip to main content

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.

  1. Run the following command to set up the configuration:
slacknotif config setconfig <job_script.py>
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slacknotifpy-1.0.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

slacknotifpy-1.0.4-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

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

Hashes for slacknotifpy-1.0.4.tar.gz
Algorithm Hash digest
SHA256 be078e9f21fc972f3ed33e995c3b1c85fc666c3c2b0eacabc92504d3cdc7b00c
MD5 c333e30b67c84d11eb549ec49c5e5264
BLAKE2b-256 16dfeb800aa2a510ee9b6c4b1218883949ac264974362b3d30b2c143ec9a02ff

See more details on using hashes here.

File details

Details for the file slacknotifpy-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for slacknotifpy-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9550f76b42eb013d74a6c08923c4bfd8da09060d833ef839651849dbf4ae974d
MD5 0f4ff12cbbcd574267c102f1a6436f53
BLAKE2b-256 1ae8d5616e3c5a25a6bbb179a683bd9d82e874522639f40f65c3f4b1271f56ae

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page