gntplib - GNTP Client Library for Python¶
gntplib is a modern Python 3 implementation of the Growl Notification Transport Protocol (GNTP) client library. It provides both synchronous and asynchronous APIs for sending notifications to GNTP-compatible notification systems.
Quick Start¶
Installation¶
Install from PyPI:
pip install gntplib
For async support with Tornado:
pip install gntplib[async]
For encryption support:
pip install gntplib[crypto]
Simple Example¶
Send a notification in just two lines:
from gntplib import publish
publish('MyApp', 'Alert', 'Hello World', 'This is a notification')
More Advanced Usage¶
from gntplib import Publisher, Event, Resource
# Define notification events
events = [
Event('update', 'Software Update', enabled=True),
Event('download', 'Download Complete', enabled=True),
]
# Create publisher with icon
icon = Resource.from_file('app_icon.png')
publisher = Publisher('MyApp', events, icon=icon)
# Register with GNTP server
publisher.register()
# Send notification
publisher.publish(
'update',
'New Version Available',
'Version 2.0 is ready to install',
priority=1,
sticky=True
)
Async Example¶
import asyncio
from gntplib.async_gntp import AsyncPublisher, AsyncResource
from gntplib import Event
async def main():
# Async resource fetching
icon = AsyncResource('https://example.com/icon.png')
# Create async publisher
publisher = AsyncPublisher('MyApp', [Event('test')], icon=icon)
publisher.register()
# Send notification
publisher.publish('test', 'Hello', 'Async notification!')
asyncio.run(main())
Key Features¶
- ✅ Modern Python 3
Type hints throughout
Async/await support with Tornado
Clean, maintainable codebase
- ✅ Full GNTP Support
REGISTER, NOTIFY, and SUBSCRIBE requests
Authentication with multiple hash algorithms
Optional encryption (AES, DES, 3DES)
- ✅ Flexible Resource Handling
Embed binary resources (icons, images)
URL-based resources
Async resource fetching
- ✅ Callback Support
Socket callbacks for click/close events
URL callbacks
Custom callback handlers
- ✅ Production Ready
Comprehensive error handling
Extensive logging support
Well-documented API
Contents¶
User Guide
API Reference
Additional Information