python - pycups 或 cups 中的订阅如何运作?

标签 python printing printers cups

我正在编写一个 python 脚本,让我可以查找打印作业。到目前为止,我的研究使我得出以下结论:

  1. 导入 pycups 模块(名为 cups)
  2. 您需要创建一个记录打印机事件的订阅
  3. 通过订阅,您可以获得每个打印作业的详细信息

pycups API文档有以下方法:

# connection.createSubscription(...)

# createSubscription(uri, events=[], job_id=-1, recipient_uri=,
#     lease_duration=-1, time_interval=-1, user_data=) -> integer

有人可以解释一下这里使用的参数及其含义,特别是 urirecipient_urievents 吗?

最佳答案

这个模块已经有一个很好的documentation .

您询问的参数如下:

  • uri:CUPS 服务器的 uri(例如 ipp://localhost:631/)
  • recipient_uri : 接收订阅通知的监听器 uri 上(例如http://localhost:)
  • events :您要订阅的事件列表(例如作业完成)

假设您的进程正在监听端口 9988,您可以订阅已完成的作业,如下所示:

subscription_id = cups_connection.createSubscription(
    uri='ipp://localhost:631',
    recipient_uri='http://localhost:9988',
    events=['job-completed']
)

关于python - pycups 或 cups 中的订阅如何运作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34327251/

相关文章:

python - Django 在 created_at 上注释

python - 如何排除负数?

c# - Word 2007 Automation - 图像在打印时显示为黑框

java - java中如何获取打印机列表?

html - 将 html 输出打印到服务器应用程序上的打印机

python - 在 CPython 中,Py_Main 的范围在哪里?

jquery - 安全休息 API

java - 查找设备的IP地址

HTML 分页符不起作用

c# - 生成图像后打印图像 [c#]