Skip to main content

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

Except-Notifier Pypi Version Python Version Code convention

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



Quick Start

pip install ExceptNotifier

or

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

Could you kindly add this badge to your repository?

![Except-Notifier](https://img.shields.io/badge/pypi-ExceptNotifier-orange)

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

ExceptNotifier-0.1.5.tar.gz (16.3 kB view hashes)

Uploaded Source

Built Distribution

ExceptNotifier-0.1.5-py3-none-any.whl (37.2 kB view hashes)

Uploaded Python 3

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