| 240 | CUPS_PRINTER_LOCAL = 0x0000 |
| 241 | CUPS_PRINTER_CLASS = 0x0001 |
| 242 | CUPS_PRINTER_REMOTE = 0x0002 |
| 243 | CUPS_PRINTER_BW = 0x0004 |
| 244 | CUPS_PRINTER_COLOR = 0x0008 |
| 245 | CUPS_PRINTER_DUPLEX = 0x0010 |
| 246 | CUPS_PRINTER_STAPLE = 0x0020 |
| 247 | CUPS_PRINTER_COPIES = 0x0040 |
| 248 | CUPS_PRINTER_COLLATE = 0x0080 |
| 249 | CUPS_PRINTER_PUNCH = 0x0100 |
| 250 | CUPS_PRINTER_COVER = 0x0200 |
| 251 | CUPS_PRINTER_BIND = 0x0400 |
| 252 | CUPS_PRINTER_SORT = 0x0800 |
| 253 | CUPS_PRINTER_SMALL = 0x1000 |
| 254 | CUPS_PRINTER_MEDIUM = 0x2000 |
| 255 | CUPS_PRINTER_LARGE = 0x4000 |
| 256 | CUPS_PRINTER_VARIABLE = 0x8000 |
| 257 | CUPS_PRINTER_IMPLICIT = 0x1000 |
| 258 | CUPS_PRINTER_DEFAULT = 0x2000 |
| 259 | CUPS_PRINTER_FAX = 0x4000 |
| 260 | CUPS_PRINTER_REJECTING = 0x8000 |
| 261 | CUPS_PRINTER_DELETE = 0x1000 |
| 262 | CUPS_PRINTER_NOT_SHARED = 0x2000 |
| 263 | CUPS_PRINTER_AUTHENTICATED = 0x4000 |
| 264 | CUPS_PRINTER_COMMANDS = 0x8000 |
| 265 | CUPS_PRINTER_OPTIONS = 0xe6ff |
| 266 | |
| 267 | |
| 667 | def getPPD(self, queuename) : |
| 668 | """Retrieves the PPD for a particular queuename.""" |
| 669 | req = self.newRequest(IPP_GET_PRINTER_ATTRIBUTES) |
| 670 | req.operation["printer-uri"] = ("uri", self.identifierToURI("printers", queuename)) |
| 671 | for attrib in ("printer-uri-supported", "printer-type", "member-uris") : |
| 672 | req.operation["requested-attributes"] = ("nameWithoutLanguage", attrib) |
| 673 | return self.doRequest(req) # TODO : get the PPD from the actual print server |
| 674 | |
646 | | def getPPD(self, queuename) : |
647 | | """Retrieves the PPD for a particular queuename.""" |
648 | | req = self.newRequest(IPP_GET_PRINTER_ATTRIBUTES) |
649 | | req.operation["printer-uri"] = ("uri", self.identifierToURI("printers", queuename)) |
650 | | for attrib in ("printer-uri-supported", "printer-type", "member-uris") : |
651 | | req.operation["requested-attributes"] = ("nameWithoutLanguage", attrib) |
652 | | return self.doRequest(req) # TODO : get the PPD from the actual print server |
653 | | |
| 685 | def getPrinters(self) : |
| 686 | """Returns the list of print queues names.""" |
| 687 | req = self.newRequest(CUPS_GET_PRINTERS) |
| 688 | req.operation["requested-attributes"] = ("keyword", "printer-name") |
| 689 | req.operation["printer-type"] = ("enum", 0) |
| 690 | req.operation["printer-type-mask"] = ("enum", CUPS_PRINTER_CLASS) |
| 691 | return [printer[1] for printer in self.doRequest(req).printer["printer-name"]] |
| 692 | |
| 693 | def getDevices(self) : |
| 694 | """Returns a list of devices as (deviceclass, deviceinfo, devicemakeandmodel, deviceuri) tuples.""" |
| 695 | answer = self.doRequest(self.newRequest(CUPS_GET_DEVICES)) |
| 696 | return zip([d[1] for d in answer.printer["device-class"]], \ |
| 697 | [d[1] for d in answer.printer["device-info"]], \ |
| 698 | [d[1] for d in answer.printer["device-make-and-model"]], \ |
| 699 | [d[1] for d in answer.printer["device-uri"]]) |
| 700 | |
| 701 | def getPPDs(self) : |
| 702 | """Returns a list of PPDs as (ppdnaturallanguage, ppdmake, ppdmakeandmodel, ppdname) tuples.""" |
| 703 | answer = self.doRequest(self.newRequest(CUPS_GET_PPDS)) |
| 704 | return zip([d[1] for d in answer.printer["ppd-natural-language"]], \ |
| 705 | [d[1] for d in answer.printer["ppd-make"]], \ |
| 706 | [d[1] for d in answer.printer["ppd-make-and-model"]], \ |
| 707 | [d[1] for d in answer.printer["ppd-name"]]) |