Skip to main content

Notification system for the pycups library.

Project description

pycups-notify

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

pycups_notify-0.0.2-py2.py3-none-any.whl (8.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page