python的咆哮通知传输协议
gntp的Python项目详细描述
这是一个python库,用于处理Growl Notification Transport Protocol
它应该可以作为旧python绑定的dropin替代品
安装
您可以使用pip进行安装
$ pip install gntp
然后测试模块
$ python -m gntp.notifier
简单用法
# GNTP uses the standard Python logging import logging logging.basicConfig(level=logging.INFO) import gntp.notifier # Simple "fire and forget" notification gntp.notifier.mini("Here's a quick message") # More complete example growl = gntp.notifier.GrowlNotifier( applicationName = "My Application Name", notifications = ["New Updates","New Messages"], defaultNotifications = ["New Messages"], # hostname = "computer.example.com", # Defaults to localhost # password = "abc123" # Defaults to a blank password ) growl.register() # Send one message growl.notify( noteType = "New Messages", title = "You have a new message", description = "A longer message description", icon = "http://example.com/icon.png", sticky = False, priority = 1, ) # Try to send a different type of message # This one may fail since it is not in our list # of defaultNotifications growl.notify( noteType = "New Updates", title = "There is a new update to download", description = "A longer message description", icon = "http://example.com/icon.png", sticky = False, priority = -1, )
基于URL的图像在OSX版本的 growl1.4页 您可以将图像与通知一起发送以解决此问题。
image = open('/path/to/image.png', 'rb').read() growl.notify( noteType = "New Messages", title = "You have a new message", description = "This time we embed the image", icon = image, )
注意
使用咆哮2及以上的用户可以选择向系统发送通知 广域通知中心。在这种情况下,icon参数将被忽略 在通知中心(总是有咆哮图标代替)。
更改日志
- v1.0.3
- 允许将file://方案用于图标
- v1.0.2
- 修复传入密码哈希的错误
- 在每个源文件中添加了有关许可证的信息
- v1.0.1
- 修复二进制数据(图像)编码错误的错误
- v1.0
- python 3.3支持
- v0.9
- 从gntp.config中删除重复的代码
- 捕获所有错误并将其重新显示为gntp.errors,以便 处理gntp库错误的其他程序。
- 确保我们以“rb”身份打开资源文件并更新文档
- v0.8
- 修复资源节缺少crlf的错误
- 修复cli客户端在选项上使用配置值的错误
- 添加对合并的支持
- v0.7
- 支持图像
- 更好的测试覆盖率支持
- 0.6
- 从~/.gntp中读取设置的configparser-aware-growlnotifier