0

I am setting up an unattended, automated printing setting. At some point the printer might run out of paper, ink, or experience some other error. I have a Canon iP4500 which on macOS communicates these kinds of errors back to the user interface. With Ubuntu/Lubuntu I have not seen such an interface.

Is there any way to get the (last) CUPS error programmatically?
I've tried

  • lpstat -p
    (which will say something like "Printing page 1, 36%" when there is no paper)
  • lpc status
  • lpq
    (which says "iP4500-series is ready and printing")
  • and dug around http://localhost:631/printers/Canon-iP4500-series, i.e. the CUPS web interface

I really don't care how "programmatically" is implemented, i.e. Python, Bash, parsing the CUPS web interface -- anything really. It just needs to be automated.

0

For python, there is the pycups lib. I needed to install libcups2-dev (on Debian 9) to successfully install and compile it. The PyPi page example (https://pypi.org/project/pycups/) is pretty straightforward:

import cups
conn = cups.Connection ()
printers = conn.getPrinters ()
for printer in printers:
    print printer, printers[printer]["device-uri"]

For what you need, I believe that the relevant info is:

printer-info: Printer name

printer-state: numeric representation of the state.

printer-state-message: a string, informing the state.

printer-state-reasons: a list of strings.

  • This sounds like a solution, but all I get is 'printer-state': 4, 'printer-state-message': 'Printing page 1, 36%', 'printer-state-reasons': ['none'] -- which is the same as lpstat -p unfortunately. (I took the paper out of the printer, and the printer's status light flashes in the corresponding pattern.) – neo post modern Mar 26 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.