0 purchases
pynotifier 0.5.0
Python Notifications
Python3 module for sending notifications.
The list of available backends:
Platform (pynotifier.backends.platform.Backend):
macOS
Linux
Windows
Email (pynotifier.backends.smtp.Backend)
Platform notifications requirements
Windows:
WinToaster - Python module
Linux:
libnotify-bin CLI tool (manual installation is required). For Ubuntu run:
sudo apt-get install libnotify-bin
Installation
Install using pip:
pip install py-notifier
Example
import ssl
import smtplib
from pynotifier import NotificationClient, Notification
from pynotifier.backends import platform, smtp
smtp_server = smtplib.SMTP_SSL('smtp.gmail.com', 465, context=ssl.create_default_context())
c = NotificationClient()
c.register_backend(platform.Backend())
c.register_backend(smtp.Backend(server=smtp_server,
name='My Organization',
email='[email protected]',
password='super_password'))
filenames = [
'path/to/file1.json',
'path/to/file2.txt',
# ...
]
attachments = []
for filename in filenames:
attachments.append(smtp.Attachment(open(filename, 'rb'), filename))
smtp_config = smtp.NotificationConfig(emails=['[email protected]', '[email protected]'],
attachments=attachments)
notification = Notification(title='Hello', message='World', smtp=smtp_config)
c.notify_all(notification)
License
The project is licensed under the terms of the MIT License,
see the LICENSE file for more information.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.