pythonmacoscups

Getting available printer trays with PyCups


I am trying to retrieve all the trays available for a printer, but I can't find a way to retrieve a list of the available trays.

This is how I am getting the printers:

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

It works just fine, but there's no information about trays in printers. Any help or reference is much appreciated thanks.

For the record, I'm working on OS X.


Solution

  • Well after several attempts here's what I've done in order to get the trays.

    For each Printer I've found, I look into /etc/cups/ppd/ for the printer_name.ppd file, in which I can find every details I need trays included.

    It's also useful as I can get the trays in each language supported in the PPDs file.