Skip to main content
pycups-notify

Python 2.7+/3.5+ PyPi package PyPi downloads

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()

The CupsEvent class has the following attributes:

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

It is possible to define a list of event types 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])

The list of existing event types is defined below:

Type

Description

CUPS_EVT_JOB_COMPLETED

Event when the job is completed

CUPS_EVT_JOB_CONFIG_CHANGED

Event when the job is changed

CUPS_EVT_JOB_CREATED

Event when a job is created

CUPS_EVT_JOB_PROGRESS

Event for job progress

CUPS_EVT_JOB_STATE_CHANGED

Event when the job-state changes

CUPS_EVT_JOB_STOPPED

Event when the job is stopped

CUPS_EVT_PRINTER_ADDED

Event when a printer is added

CUPS_EVT_PRINTER_CHANGED

Event when a printer is changed

CUPS_EVT_PRINTER_CONFIG_CHANGED

Event when a printer’s configuration is changed

CUPS_EVT_PRINTER_DELETED

Event when a printer is deleted

CUPS_EVT_PRINTER_MODIFIED

Event when a printer is modified

CUPS_EVT_PRINTER_STATE_CHANGED

Event when the printer-state changes

CUPS_EVT_PRINTER_STOPPED

Event when a printer is stopped

CUPS_EVT_SERVER_AUDIT

Event when a bad request, security error, or authentication error occurs

CUPS_EVT_SERVER_RESTARTED

Event when the server is restarted

CUPS_EVT_SERVER_STARTED

Event when the server is initially started

CUPS_EVT_SERVER_STOPPED

Event when the server is shutdown

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

Metadata

Release files for pycups-notify 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycups-notify 0.0.6
File Size Uploaded
pycups-notify-0.0.6.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pycups-notify 0.0.6
File Interpreter ABI Platform
pycups_notify-0.0.6-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 16.0 kB

Release files / pycups-notify-0.0.6.tar.gz

Download URL pycups-notify-0.0.6.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1efcf8d3e58c409dc2152edd824650a9eff59eeee596e7819fccd152e40e7545
BLAKE2b-256 checksum
How to use checksums
c106a717782e01b5502440301038868d8512131fbeaa8a80a543cf8cf0803d56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / pycups_notify-0.0.6-py2.py3-none-any.whl

Download URL pycups_notify-0.0.6-py2.py3-none-any.whl
Size 8.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
96777f380c2df11bacc4e714475376ffc3c2e0a5deb5d585469752d6313d5a32
BLAKE2b-256 checksum
How to use checksums
fb24daba6c51c4fab7e51abafaa6f7c6e5991219fdffc80d25e7eb0a47530aee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page