How to use the escpos.printer.File 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_printer_file.py View on Github external
def test_load_file_printer(mocker, path):
    """test the loading of the file-printer"""
    mock_escpos = mocker.patch('escpos.escpos.Escpos.__init__')
    mock_open = mocker.patch(mock_open_call)
    printer.File(devfile=path)
    assert mock_escpos.called
    mock_open.assert_called_with(path, "wb")
github python-escpos / python-escpos / test / test_printer_file.py View on Github external
def test_flush_on_close(mocker, txt):
    """test flush on close in file-printer"""
    mock_open = mocker.patch(mock_open_call)
    mock_device = mocker.patch.object(printer.File, 'device')

    p = printer.File(auto_flush=False)
    # inject the mocked device-object
    p.device = mock_device
    p._raw(txt)
    assert not mock_device.flush.called
    p.close()
    assert mock_device.flush.called
    assert mock_device.close.called
github python-escpos / python-escpos / test / test_printer_file.py View on Github external
def test_auto_flush(mocker, txt):
    """test auto_flush in file-printer"""
    mock_escpos = mocker.patch('escpos.escpos.Escpos.__init__')
    mock_open = mocker.patch(mock_open_call)
    mock_device = mocker.patch.object(printer.File, 'device')

    p = printer.File(auto_flush=False)
    # inject the mocked device-object
    p.device = mock_device
    p._raw(txt)
    assert not mock_device.flush.called
    mock_device.reset_mock()
    p = printer.File(auto_flush=True)
    # inject the mocked device-object
    p.device = mock_device
    p._raw(txt)
    assert mock_device.flush.called
github paxapos / fiscalberry / Drivers / ReceiptFileDriver.py View on Github external
'''Para testing y desarrollo'''

# -*- coding: utf-8 -*-

import socket
from escpos import printer
from DriverInterface import DriverInterface


TCP_PORT = 9100

from DriverInterface import DriverInterface


class ReceiptFileDriver(printer.File, DriverInterface):
    """ Generic file printer
    This class is used for parallel port printer or other printers that are directly attached to the filesystem.
    Note that you should stay away from using USB-to-Parallel-Adapter since they are unreliable
    and produce arbitrary errors.
    inheritance:
    .. inheritance-diagram:: escpos.printer.File
        :parts: 1
    """

    def __init__(self, devfile="/dev/usb/lp0", auto_flush=True, *args, **kwargs):
        printer.File.__init__(self, devfile, auto_flush, *args, **kwargs)
    
    def start(self):
        pass
github paxapos / fiscalberry / Drivers / ReceiptFileDriver.py View on Github external
def __init__(self, devfile="/dev/usb/lp0", auto_flush=True, *args, **kwargs):
        printer.File.__init__(self, devfile, auto_flush, *args, **kwargs)
github paxapos / fiscalberry / bemafix.py View on Github external
# Drivers:

from Drivers.EpsonDriver import EpsonDriver
from Drivers.FileDriver import FileDriver
from Drivers.HasarDriver import HasarDriver
from Drivers.DummyDriver import DummyDriver

from Comandos.EpsonComandos import EpsonComandos
from Comandos.HasarComandos import HasarComandos
from math import ceil

from Traductor import Traductor
from escpos import printer


barra = printer.File("/tmp/asas.txt")
texto = u"ñandú imprimiendo caracteres raros\nÑasasas\n"

# colocar en modo ESC P
barra._raw(chr(0x1D)+chr(0xF9)+chr(0x35)+"1")

#1D F9 37 n CP850
#barra._raw(chr(0x1D) + chr(0xF9) + chr(0x37) + "2")
barra.charcode("WEST_EUROPE")
barra._raw(chr(0x1D) + chr(0xF9) + chr(0x37) + "2")
barra.text(texto)


barra.cut()

barra._raw(chr(0x1D)+chr(0xF9)+chr(0x35)+"0")