Notification system for the pycups library.
Project description
The pycups-notify library is an extension to the pycups one. It enables subscription to CUPS RSS notifications.
This library implements the Event notify pattern to match with the design description of the CUPS server.
Install
$> pip install pycups-notify
Usage
import time
import cups
from cups_notify import Subscriber
def on_event(evt):
print(evt)
# Create a CUPS connection
conn = cups.Connection()
# Create a new subscriber
sub = Subscriber(conn)
# Subscribe the callback to all CUPS events
sub.subscribe(on_event)
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
pass
finally:
sub.unsubscribe_all()
It is possible to define a list of events on which the callback is binded:
import cups
from cups_notify import Subscriber, event
def my_callback(evt):
print(evt.title, evt.description)
# Create a new subscriber
sub = Subscriber(cups.Connection())
# Subscribe the callback
sub.subscribe(my_callback, [event.CUPS_EVT_JOB_CREATED,
event.CUPS_EVT_JOB_COMPLETED,
event.CUPS_EVT_JOB_STOPPED])
If the CUPS server is not running on the same computer as the subscriber application one, the local IP address (same network than the CUPS server) have to be provided to the subscriber class:
# Create a CUPS connection
cups.setServer('198.20.34.1')
conn = cups.Connection()
# Create a new subscriber
sub = Subscriber(conn, '198.20.34.26')
Run
A simple listener can be started by typing the following command line:
$> pycups-notify
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for pycups_notify-0.0.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 898a4e7c8aae54fa3d09da2ecf9265ba75e5edb0abcbc4828b4dac67a769e5ba |
|
MD5 | 76417125f9d21cd46e9e42a7889cd7b4 |
|
BLAKE2b-256 | 04fb7b58bf89119c0d60ab47642f7b0d8e3d95876649872fbaa6c3832b728adb |