Crete and send Slack messages and alerts through a webhook
Project description
Slackertpy
A simple way to create and send Slack messages through a webhook.
Especially useful for logging and alerting, supports three logging levels Error, Info, Debug and templates to simplify sending the same layout message with different content.
This is a port from a Ruby library Slackert. Follow Slackert's documnetation for in depth description of classes and methods.
Installation
Install using pip
pip install slackertpy
Usage
Slackert sends message through an incoming webhook.
Initialize alerr client that will handle sending out your messages
from slackertpy import Alerter
alerter = Alerter('your-webhook-url)
Create a message with templates
from slackertpy import templates
simple_message = templates.notification(
text="Hello from Slackert!"
)
Send it on its way with alerter
alerter.info(simple_message)
You can use richer templates or compose messages from scratch using MessageBuilder. Consult the documentation for more information.
alert = templates.notification(text='Incoming debug info!', title='Silly Little Job')
alerter.debug(alert)
alert = templates.job_executed(
title='Process ABC',
result='Success',
overview={
'Start Time': process_start_time,
'Server Location': 'US'
},
stats={
'Records': 12345,
'Retries': 3
}
)
alerter.info(alert)
Tag users to notify them an exception was raised
error_alert = templates.job_error(
title='Process ABC',
error=error_output,
notify_user_ids=['MemberID1', 'MemberID2'],
extra={
'Retries': num_retries
}
)
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
File details
Details for the file slackertpy-0.1.3.tar.gz.
File metadata
- Download URL: slackertpy-0.1.3.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff6e59f0d056e4d94590cc12a20a12f37ee3aadb210a68d298b7685212298191
|
|
| MD5 |
5628d232bf545658fd59c8385d6da0d6
|
|
| BLAKE2b-256 |
af147d1ac78839978436abf0c4b19f2aaaf0b4497ebd7230c35731570f56921b
|