Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
device.pxWidth = settings['pxWidth']
# Set default widht with normal value
device.width = device.widthA = settings['WidthA']
device.widthB = settings['WidthB']
# Set correct table character
if 'charSet' in settings:
device.text(settings['charSet'])
template = config.get('receipt.template')
# Render and print receipt
tmphandler.print_receipt(device, template, receipt)
elif ptype == 'serial':
# TODO:
printer.Serial(settings['devfile'])
elif ptype == 'network':
# TODO:
printer.Network(settings['host'])
# -*- coding: utf-8 -*-
import socket
from escpos import printer, escpos
import threading
import time
from DriverInterface import DriverInterface
# TCP_PORT = 9100
class ReceiptDirectJetDriver(printer.Network, DriverInterface):
connected = False
def __init__(self, host, port=9100, timeout=10, codepage="cp858", mac="", *args, **kwargs):
""" escrito aqui solo para tener bien en claro las variables iniciales"""
"""
:param host : Printer's hostname or IP address
:param port : Port to write to
:param timeout : timeout in seconds for the socket-library
:param codepage : codepage default to cp858
"""
escpos.Escpos.__init__(self, *args, **kwargs)
self.host = host
self.port = port
self.timeout = timeout
self.codepage = codepage
def is_alive():
from proxypos.proxypos import config
# Init printer
ptype = config.get('printer.type').lower()
settings = config.get('printer.settings')
idVendor = settings['idVendor']
idProduct = settings['idProduct']
if ptype == 'usb':
with printer.Usb(idVendor, idProduct) as device:
pass
elif ptype == 'serial':
# TODO:
printer.Serial(settings['devfile'])
elif ptype == 'network':
# TODO:
printer.Network(settings['host'])
def connect_to_printer(self):
NETWORK_PRINTER_IP = config['twitter_printer_ip']
if self.printer:
self.printer.close()
try:
self.printer = Network(NETWORK_PRINTER_IP)
except:
_logger.error("Can not get printer with IP: %s" % NETWORK_PRINTER_IP)
self.printer = False
def open_cashbox():
from proxypos.proxypos import config
# Init printer
ptype = config.get('printer.type').lower()
settings = config.get('printer.settings')
idVendor = settings['idVendor']
idProduct = settings['idProduct']
if ptype == 'usb':
with printer.Usb(idVendor, idProduct) as device:
device.cashdraw(2)
elif ptype == 'serial':
# TODO:
printer.Serial(settings['devfile'])
elif ptype == 'network':
# TODO:
printer.Network(settings['host'])