How to use the escpos.printer.Dummy function in escpos

To help you get started, we’ve selected a few escpos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-escpos / python-escpos / test / test_function_text.py View on Github external
def get_printer():
    return Dummy(magic_encode_args={'disabled': True, 'encoding': 'CP437'})
github python-escpos / python-escpos / test / test_function_qr_native.py View on Github external
def test_size():
    """Test QR box size"""
    instance = printer.Dummy()
    instance.qr("1234", native=True, size=7)
    expected = b'\x1d(k\x04\x001A2\x00\x1d(k\x03\x001C\x07\x1d(k\x03\x001E0\x1d' \
        b'(k\x07\x001P01234\x1d(k\x03\x001Q0'
    assert(instance.output == expected)
github python-escpos / python-escpos / test / test_function_panel_button.py View on Github external
def test_function_panel_button_on():
    """test the panel button function (enabling) by comparing output"""
    instance = printer.Dummy()
    instance.panel_buttons()
    assert(instance.output == b'\x1B\x63\x35\x00')
github python-escpos / python-escpos / test / test_functions.py View on Github external
def test_line_spacing_code_gen():
    printer = Dummy()
    printer.line_spacing(10)
    assert printer.output == b'\x1b3\n'
github python-escpos / python-escpos / test / test_function_barcode.py View on Github external
def test_code_check(bctype, data):
    """should raise an error if the barcode code is invalid.
    """
    instance = printer.Dummy()
    with pytest.raises(BarcodeCodeError):
        instance.barcode(data, bctype)

    assert instance.output == b''
github python-escpos / python-escpos / test / test_function_image.py View on Github external
def test_graphics_both():
    """
    Test printing black/white graphics
    """
    instance = printer.Dummy()
    instance.image('test/resources/black_white.png', impl="graphics")
    assert(instance.output == b'\x1d(L\x0c\x000p0\x01\x011\x02\x00\x02\x00\xc0\x00\x1d(L\x02\x0002')
github python-escpos / python-escpos / test / test_load_module.py View on Github external
def test_instantiation():
    """test the instantiation of a escpos-printer class and basic printing"""
    instance = printer.Dummy()
    instance.text('This is a test\n')
github python-escpos / python-escpos / examples / codepage_tables.py View on Github external
def main():
    dummy = printer.Dummy()

    dummy.hw('init')

    for codepage in sys.argv[1:] or ['USA']:
        dummy.set(height=2, width=2)
        dummy._raw(codepage + "\n\n\n")
        print_codepage(dummy, codepage)
        dummy._raw("\n\n")

    dummy.cut()

    print(dummy.output)
github mrf345 / FQM / app / printer.py View on Github external
mt.paste(st_7, (0, tts))
    tts += st_7.size[1]
    mt.paste(st_5, (0, tts))
    tts += st_5.size[1]
    mt.paste(st_6, (0, tts))

    sffs = []
    sfs = [
        f'{uuid.uuid4()}'.replace('-', '') + '.jpg',
        f'{uuid.uuid4()}'.replace('-', '') + '.txt'
    ]

    for f in sfs:
        sffs.append(path.join(getcwd(), f))
    mt.save(sfs[0], format="JPEG")
    p = Dummy()
    p.image(sfs[0], fragment_height=tt, high_density_vertical=True)
    p.cut()
    f = open(sfs[1], 'wb+')
    f.write(p.output)
    p.close()
    f.close()

    text = f'print /D:\\\localhost\\"{pname}" "{sfs[1]}"'
    system(text)
    for f in sffs:
        if path.isfile(f):
            remove(f)