3

I am using the python cups module to list the available destinations. And everything work perfectly. I've installed the pycups using sudo apt-get install pycups.

import cups

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

The problem is that I am not finding a documentation for this module and what are the methods that can be used so can implement other functionalities.

Do you have an idea where I can find the documentation?

starball
  • 20,030
  • 7
  • 43
  • 238
ShZnd
  • 69
  • 1
  • 2
  • 9

3 Answers3

1

I ran into the same problem. There is one example in their github and that's all I could find. You should probably poke around with a python debugger to learn how the library works.

user8466
  • 31
  • 1
  • 2
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/32245612) – Wouter Jul 18 '22 at 19:00
1

You can use built-in help function in python interpreter:

>>> import cups
>>> help(cups)
# shows auto-generated documentation for cups module
loloToster
  • 1,395
  • 3
  • 5
  • 19
1

You can use the built-in help function mentioned in the above answer. Here is an example of printing a file using pycups

 |  printFile(...)
 |      printFile(printer, filename, title, options) -> integer
 |      
 |      Print a file.
 |      
 |      @type printer: string
 |      @param printer: queue name
 |      @type filename: string
 |      @param filename: local file path to the document
 |      @type title: string
 |      @param title: title of the print job
 |      @type options: dict
 |      @param options: dict of options
 |      @return: job ID
 |      @raise IPPError: IPP problem

printFile needs 4 parameters. I passed an empty dictionary because it was necessary and also I am using the first available printer

import cups
conn = cups.Connection ()
printers = conn.getPrinters ()
# printers is a dictionary containing information about all the printers available

emptyDict = {}
AvailablePrinters = list(printers.keys())
PrinterUsing = AvailablePrinters[0]
conn.printFile(PrinterUsing, "./FileName", "title", emptyDict)
MapSec
  • 11
  • 2