Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to monitor the printer's event? #59

Open
DonkeyJason opened this issue Apr 3, 2024 · 1 comment
Open

How to monitor the printer's event? #59

DonkeyJason opened this issue Apr 3, 2024 · 1 comment

Comments

@DonkeyJason
Copy link

I have tried conn.createSubscription and pycups-notify package, they are both not working.
1 For the conn.createSubscription, my code is:
sub_id = conn.createSubscription( uri="ipp://localhost:631/printers/cups_new_printer_2", events=['all'], recipient_uri='http://localhost:8000/abc', )
It's always raise the error about "cups.IPPError: (1028, 'client-error-not-possible')".
It seems the recipient_uri is not correct, I tried the "ippget://localhost:8000/abc", "http://localhost:8000/abc", always not working.

2 Fot the pycuos-notify package, my code is:
`import cups
from cups_notify import Subscriber, event

def my_callback(evt):
print(evt)

def start_listener():
cups.setServer('127.0.0.1')
conn = cups.Connection()
sub = Subscriber(conn, '127.0.0.1')
sub.subscribe(
my_callback,
[
event.CUPS_EVT_JOB_COMPLETED, # Event when the job is completed
event.CUPS_EVT_JOB_CONFIG_CHANGED, # Event when the job is changed
event.CUPS_EVT_JOB_CREATED, # Event when a job is created
event.CUPS_EVT_JOB_PROGRESS, # Event for job progress
event.CUPS_EVT_JOB_STATE_CHANGED, # Event when the job-state changes
event.CUPS_EVT_JOB_STOPPED, # Event when the job is stopped
event.CUPS_EVT_PRINTER_ADDED, # Event when a printer is added
event.CUPS_EVT_PRINTER_CHANGED, # Event when a printer is changed
event.CUPS_EVT_PRINTER_CONFIG_CHANGED, # Event when a printer’s configuration is changed
event.CUPS_EVT_PRINTER_DELETED, # Event when a printer is deleted
event.CUPS_EVT_PRINTER_MODIFIED, # Event when a printer is modified
event.CUPS_EVT_PRINTER_STATE_CHANGED, # Event when the printer-state changes
event.CUPS_EVT_PRINTER_STOPPED, # Event when a printer is stopped
event.CUPS_EVT_SERVER_AUDIT, # Event when a bad request, security error, or authentication error occurs
event.CUPS_EVT_SERVER_RESTARTED, # Event when the server is restarted
event.CUPS_EVT_SERVER_STARTED, # Event when the server is initially started
event.CUPS_EVT_SERVER_STOPPED, # Event when the server is shutdown
]
)`
There is no result.

I don't think the conn.getJobs() is a perfect solution, so prefer the event monitor solution.

@dantetemplar
Copy link

upvote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants