pycups icon indicating copy to clipboard operation
pycups copied to clipboard

How to monitor the printer's event?

Open DonkeyJason opened this issue 10 months ago • 0 comments

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.

DonkeyJason avatar Apr 03 '24 01:04 DonkeyJason