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.stop()
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.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afbec0a2f0639095a229ee996cf0b7e394673bc4cb73f828ebf5922e16e4a013 |
|
MD5 | dbe1823d4d5beab4496da4f9785441c8 |
|
BLAKE2b-256 | 6b816c8d122984deabef92bfeb9e8b009d8e02e84afa7518434a4f7329923406 |