Getting the list of available printers/classes - from Pure Python?
Helge Blischke
h.blischke at srz.de
Fri Feb 17 07:29:09 PST 2006
Erik Forsberg wrote:
>
> Hi!
>
> I'd like to get hold of the list of available printers from a python
> program, without using a C extension (that is, I don't want to link to
> the standard cups C libraries). The reason for not linking to the C
> libraries is that it's much harder to distribute the software when it
> needs C extensions (which are python-version-specific, IIRC).
>
> Any ideas on this? Is there a binary always present on a host with
> CUPS installed I can run and parse output from? Should I talk directly
> to CUPS on 127.0.0.1:631 and issue a IPP request?
>
> Thanks,
> \EF
> --
> Erik Forsberg OpenSource-based Thin Client Technology
> Cendio AB Phone: +46-13-21 46 00
> Web: http://www.cendio.com
>
The "quick and dirty" method is to execute the lpstat -p command and digest its output
(or use the lpc command if you are more of a BSD fan).
The usual CUPS install installs both the sysv and the bsd style commands.
But, of course, the nice expensive method is to construct an IPP request and
parse the answer ...
Helge
--
Helge Blischke
Softwareentwicklung
SRZ Berlin | Firmengruppe besscom
http://www.srz.de
More information about the cups
mailing list