Skip to main content

Notification system for the pycups library.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycups-notify-0.0.6.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

pycups_notify-0.0.6-py2.py3-none-any.whl (8.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pycups-notify-0.0.6.tar.gz.

File metadata

  • Download URL: pycups-notify-0.0.6.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for pycups-notify-0.0.6.tar.gz
Algorithm Hash digest
SHA256 1efcf8d3e58c409dc2152edd824650a9eff59eeee596e7819fccd152e40e7545
MD5 c35d8ae85fbc863b687e11ff7feb1b5b
BLAKE2b-256 c106a717782e01b5502440301038868d8512131fbeaa8a80a543cf8cf0803d56

See more details on using hashes here.

File details

Details for the file pycups_notify-0.0.6-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pycups_notify-0.0.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 96777f380c2df11bacc4e714475376ffc3c2e0a5deb5d585469752d6313d5a32
MD5 3a9887defb1202178a50db55db29054a
BLAKE2b-256 fb24daba6c51c4fab7e51abafaa6f7c6e5991219fdffc80d25e7eb0a47530aee

See more details on using hashes here.

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