Пример #1
0
def list_printers(q):

    "List printers"
    printers = cupsext.getPrinters()
    for printer in printers:
        printer_state = printer.state
        printer_state_info = ""

        if printer_state == 3:
            printer_state_info = "The destination is idle"
        elif printer_state == 4:
            printer_state_info = "The destination is printing a job"
        elif printer_state == 5:
            printer_state_info = "The destination is stopped"
        else:
            printer_state_info = "State undefined"

        if len(q) > 0:
            if (printer.name.find(q) != -1 or printer.info.find(q) != -1 or
                printer.device_uri.find(q) != -1):
                print   "ID: %s\n \tDescription: %s \n \tLocate: %s " \
                        "\n \tState: %s\n" % (printer.name, printer.info,
                        printer.device_uri, printer_state_info)
            else:
                print   "ID: %s\n \tDescription: %s \n \tLocate: %s " \
                        "\n \tState: %s\n" % (printer.name, printer.info,
                        printer.device_uri, printer_state_info)
Пример #2
0
def getPrinters():
##    p2 = []
##    p = cupsext.getPrinters()
##    for pp in p:
##        print pp
##        try:
##            pn = pp.name.decode('utf-8')
##        except UnicodeError:
##            pass
##
##        p2.append(pp)
##
##    return p2
    return cupsext.getPrinters()
Пример #3
0
def getPrinters():
    ##    p2 = []
    ##    p = cupsext.getPrinters()
    ##    for pp in p:
    ##        print pp
    ##        try:
    ##            pn = pp.name.decode('utf-8')
    ##        except UnicodeError:
    ##            pass
    ##
    ##        p2.append(pp)
    ##
    ##    return p2
    return cupsext.getPrinters()