pycups库的通知系统。
pycups-notif的Python项目详细描述
pycups-notify库是pycups的扩展 一个。它支持订阅CUPS RSS通知。在
此库实现Event notify 与design description匹配的模式 CUPS服务器的。在
安装
$> pip install pycups-notify
使用
^{pr2}$CupsEvent类具有以下属性:
Attribute | type | Description |
---|---|---|
guid | int | Unique ID |
title | str | Title |
description | str | Description |
printer | str | Printer name |
address | tuple | Address of the CUPS server |
timestamp | datetime | Published date |
可以定义绑定回调的事件类型列表:
importcupsfromcups_notifyimportSubscriber,eventdefmy_callback(evt):print(evt.title,evt.description)# Create a new subscribersub=Subscriber(cups.Connection())# Subscribe the callbacksub.subscribe(my_callback,[event.CUPS_EVT_JOB_CREATED,event.CUPS_EVT_JOB_COMPLETED,event.CUPS_EVT_JOB_STOPPED])
现有事件类型的列表定义如下:
^{tb2}$如果CUPS服务器与订阅服务器应用程序不在同一台计算机上运行 第一,本地IP地址(与CUPS服务器相同的网络)必须提供给 订户类:
# Create a CUPS connectioncups.setServer('198.20.34.1')conn=cups.Connection()# Create a new subscribersub=Subscriber(conn,'198.20.34.26')
跑
可以通过键入以下命令行启动简单的侦听器:
$> pycups-notify
- 项目
标签: