zprinter.py
def detect_printer():
    """ Look for 'GK420' tags in printer list.

    This code has been tested on a Windows machine and a Raspberry Pi
    (Ubuntu).
    """
    SEARCH_STRING = "GK420"
    z = zebra()

    # Identify which operating system is being used and find the printer
    # printer_present = False
    if IS_WINDOWS:
        print("Running on Windows...", end=" ")

        # Obtain a list of previously attached devices from the system
        # printer device lists
        printer_queues = z._getqueues_win()

        # Obtain a list of all currently attached devices
        dm = DeviceManager()
        devices = dm.all_devices

        # Check if A ZDesigner GK420 printer is available.
        for dev in devices:
            if SEARCH_STRING in dev.description:
                if dev.children[0].friendly_name in printer_queues:
                    print("found printer: {}".format(dev.children[0].friendly_name))
                    z.setqueue(dev.children[0].friendly_name)
                    printer_present = dev.children[0].friendly_name
                    break
            else:
                printer_present = False

    else:
        print("Running on Unix... configure printer setting:")
        try:
            printers = [device for device in z.getqueues() if SEARCH_STRING in device]
            print("")
            for i, printer in enumerate(printers):
                print("  {}: {}".format(i, printer))

            printer_present = printers[PRINTER_QUEUE_POSITION]
            z.setqueue(printer_present)

        except Exception:
            print("Check that 'PRINTER_QUEUE_POSITION' is correctly configured.")
            printer_present = False

    if printer_present:
        print("Attached to: {}".format(printers[PRINTER_QUEUE_POSITION]))
    else:
        print("Unable to find '{}' printer.".format(SEARCH_STRING))

    return(z)
 Look for 'GK420' tags in printer list.

    This code has been tested on a Windows machine and a Raspberry Pi
    (Ubuntu).
    
Look for 'GK420' tags in printer list.
This code has been tested on a Windows machine and a Raspberry Pi
(Ubuntu).
Look for ' GK420 ' tags in printer list . This code has been tested on a Windows machine and a Raspberry Pi ( Ubuntu ) .
def detect_printer():
    SEARCH_STRING = "GK420"
    z = zebra()
    if IS_WINDOWS:
        print("Running on Windows...", end=" ")
        printer_queues = z._getqueues_win()
        dm = DeviceManager()
        devices = dm.all_devices
        for dev in devices:
            if SEARCH_STRING in dev.description:
                if dev.children[0].friendly_name in printer_queues:
                    print("found printer: {}".format(dev.children[0].friendly_name))
                    z.setqueue(dev.children[0].friendly_name)
                    printer_present = dev.children[0].friendly_name
                    break
            else:
                printer_present = False
    else:
        print("Running on Unix... configure printer setting:")
        try:
            printers = [device for device in z.getqueues() if SEARCH_STRING in device]
            print("")
            for i, printer in enumerate(printers):
                print("  {}: {}".format(i, printer))
            printer_present = printers[PRINTER_QUEUE_POSITION]
            z.setqueue(printer_present)
        except Exception:
            print("Check that 'PRINTER_QUEUE_POSITION' is correctly configured.")
            printer_present = False
    if printer_present:
        print("Attached to: {}".format(printers[PRINTER_QUEUE_POSITION]))
    else:
        print("Unable to find '{}' printer.".format(SEARCH_STRING))
    return(z)
def detect_printer ( ) : SEARCH_STRING = "GK420" z = zebra ( ) if IS_WINDOWS : print ( "Running on Windows..." , end = " " ) printer_queues = z . _getqueues_win ( ) dm = DeviceManager ( ) devices = dm . all_devices for dev in devices : if SEARCH_STRING in dev . description : if dev . children [ 0 ] . friendly_name in printer_queues : print ( "found printer: {}" . format ( dev . children [ 0 ] . friendly_name ) ) z . setqueue ( dev . children [ 0 ] . friendly_name ) printer_present = dev . children [ 0 ] . friendly_name break else : printer_present = False else : print ( "Running on Unix... configure printer setting:" ) try : printers = [ device for device in z . getqueues ( ) if SEARCH_STRING in device ] print ( "" ) for i , printer in enumerate ( printers ) : print ( "  {}: {}" . format ( i , printer ) ) printer_present = printers [ PRINTER_QUEUE_POSITION ] z . setqueue ( printer_present ) except Exception : print ( "Check that 'PRINTER_QUEUE_POSITION' is correctly configured." ) printer_present = False if printer_present : print ( "Attached to: {}" . format ( printers [ PRINTER_QUEUE_POSITION ] ) ) else : print ( "Unable to find '{}' printer." . format ( SEARCH_STRING ) ) return ( z )
Look for 'GK420' tags in printer list.
Look for ' GK420 ' tags in printer list .
""" Look for 'GK420' tags in printer list.

    This code has been tested on a Windows machine and a Raspberry Pi
    (Ubuntu).
    """ # Identify which operating system is being used and find the printer # printer_present = False # Obtain a list of previously attached devices from the system # printer device lists # Obtain a list of all currently attached devices # Check if A ZDesigner GK420 printer is available.