With Python's try-except to receive notifications about Errors or Successes in your code through messenger app or email.
Project description
Development Status :: 3 - Alpha
Copyright (c) 2023 MinWoo Park, South Korea
Python Package: ExceptNotifier
Provides a notification from the application shown in the following screen,
The ExceptNotifier
Python package offers a flexible approach to receiving notifications by enhancing Python's try-except statement. This package enables you to receive alerts through various messaging applications or emails.
With ExceptNotifier
, you can obtain detailed compilation errors, including debug information, sent directly to your preferred messaging platform or email. By integrating OpenAI's ChatGPT, you can receive additional error code information as long as you provide the required API model name and key. This feature ensures that error handling and notifications are more informative and accessible, streamlining your debugging process.
Supporting Applications
- Telegram
- Discord
- Slack
- Google Mail
- SMS Sending using Twilio
- Desktop Notification using Plyer
- Line
- AWS Chime
- Microsoft Teams
- Kakao Talk
Quick Start
pip install ExceptNotifier
Features
Telegram Notifier
- a. Open your telegram app and search for BotFather. (A built-in Telegram bot that helps users create custom Telegram bots)
- b. Type /newbot to create a new bot
- c. Give your bot a name & a username
- d. Copy your new Telegram bot’s token
For more infomation, visit Telegram Bot Father API
from ExceptNotifier import ExceptTelegram, SuccessTelegram, SendTelegram
import sys
sys.excepthook = ExceptTelegram.__call__
_TELEGRAM_TOKEN = "xxxx"
try:
print(1/0)
SuccessTelegram().__call__() #1. success sender
except ExceptTelegram as e: #2. except sender
sys.exit()
SendTelegram().__call__() #3. customized sender
Mail Notifier
In the except statement, an email is sent along with the error message. Additionally, you can send emails from any desired line.
- a. Log in with the sender's email ID.
- b. Obtain an app password for sending Google Mail at the following link or google document.
from ExceptNotifier import ExceptMail, SuccessMail, SendMail
sys.excepthook = ExceptMail.__call__
try:
main() # Your Code Here
SuccessMail().__call__() # No Exception -> Send Success mail.
except ExceptMail: # Exception -> Send Fail mail.
pass
SendMail().__call__() # When Process Ended -> Any Line mail.
See Example...
import sys
from ExceptNotifier import ExceptMail, SuccessMail, SendMail
# 01. Set variable
_gmail_receiver = 'xxxxx@gmail.com'
_gmail_sender = 'xxxxx@gmail.com'
_gmail_app_password_of_sender = 'xxxxx'
sys.excepthook = ExceptMail.__call__
try:
# 02.Locate your code
print(1/0)
SuccessMail().__call__() # Success Mail
except ExceptMail as e: # Exception Mail
sys.exit()
print(e)
SendMail().__call__() # Put Any Line: Sending mail
Snippet for Python developers...
import sys
from ExceptNotifier import ExceptMail, SuccessMail, SendMail
global _gmail_receiver, _gmail_sender, _gmail_app_password_of_sender
_gmail_receiver = 'xxxxxxx@gmail.com'
_gmail_sender = 'yyyyyy@gmail.com'
_gmail_app_password_of_sender = 'zzzzzz'
sys.excepthook = ExceptMail.__call__
try:
'your code'
SuccessMail().__call__()
except ExceptMail:
pass
SendMail().__call__()
Inspiring
- Thanks to Myunghak Lee for providing great ideas on providing debugging information through open ai API.
Contacts
- Maintainer Daniel Park, South Korea
- Email parkminwoo1991@gmail.com
Could you kindly add this badge to your repository?
![Except-Notifier](https://img.shields.io/badge/pypi-ExceptNotifier-orange)
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
Hashes for ExceptNotifier-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9a60f65a1da4bf3fc1e26ac29c9a76ccee0e808394d53da86c4911aa81e7592 |
|
MD5 | 9b4525e0dfc6526fc9c1efc1d449af06 |
|
BLAKE2b-256 | a960ed7c611fc7b8b3cebfd2ca252ad8de214233fce8d9318dd774dec8540f64 |