Growl Notification Transport Protocol for Python
80
Build a notification sender that validates server responses and handles various error conditions properly.
Your task is to implement a notification system with the following features:
Your implementation must handle the following error scenarios:
@generates
class NotificationClient:
"""
A notification client that sends notifications with proper error handling.
"""
def __init__(self, hostname='localhost', port=23053, password=None):
"""
Initialize the notification client.
Args:
hostname: The server hostname
port: The server port
password: Optional password for authentication
"""
pass
def register(self, app_name, notification_types):
"""
Register the application with the server.
Args:
app_name: Name of the application
notification_types: List of notification type names to register
Raises:
ConnectionError: If unable to connect to the server
ValueError: If the server response is invalid
AuthenticationError: If authentication fails
"""
pass
def send_notification(self, notification_type, title, description=''):
"""
Send a notification to the server.
Args:
notification_type: The type of notification (must be registered)
title: Notification title
description: Optional notification description
Raises:
ConnectionError: If unable to connect to the server
ValueError: If the server response is invalid or notification type not registered
AuthenticationError: If authentication fails
"""
pass
class AuthenticationError(Exception):
"""Raised when authentication with the server fails."""
passProvides GNTP protocol implementation for sending notifications.
Install with Tessl CLI
npx tessl i tessl/pypi-gntpevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10