Пример #1
0
class WSHandler(tornado.websocket.WebSocketHandler):
    def initialize(self, ref_object):
        self.fbApp = ref_object
        self.clients = []
        self.traductor = TraductoresHandler(self, self.fbApp)

    def open(self):
        self.clients.append(self)
        logger.info('Connection Established')

    def on_message(self, message):
        traductor = self.traductor
        response = {}
        logger.info("Request \n -> %s" % message)
        try:
            jsonMes = json.loads(message, strict=False)
            response = self.traductor.json_to_comando(jsonMes)
        except TypeError, e:
            errtxt = "Error parseando el JSON %s" % e
            logger.exception(errtxt)
            response["err"] = errtxt
        except TraductorException, e:
            errtxt = "Traductor Comandos: %s" % str(e)
            logger.exception(errtxt)
            response["err"] = errtxt
Пример #2
0
class WSHandler(tornado.websocket.WebSocketHandler):
    def initialize(self, ref_object):
        self.fbApp = ref_object
        self.clients = []
        self.traductor = TraductoresHandler(self, self.fbApp)

    def open(self):
        self.clients.append(self)
        logger.info('new connection')

    def on_message(self, message):
        traductor = self.traductor
        response = {}
        logger.info("----- - -- - - - ---")
        logger.info(message)
        try:
            jsonMes = json.loads(message, strict=False)
            response = self.traductor.json_to_comando(jsonMes)
        except TypeError, e:
            errtxt = "Error parseando el JSON %s" % e
            logger.error(errtxt)
            response["err"] = errtxt
            import sys, traceback
            traceback.print_exc(file=sys.stdout)
        except TraductorException, e:
            errtxt = "Traductor Comandos: %s" % str(e)
            logger.error(errtxt)
            response["err"] = errtxt
            import sys, traceback
            traceback.print_exc(file=sys.stdout)
Пример #3
0
def jsontest():
    jsoncomando = {
        "printerName": "fiscalEpson",
        "printTicket": {
            "encabezado": {
                "tipo_cbte": "FB",
                "imprimir_fecha_remito": 1
            },
            "items": [
                {
                    "alic_iva": "21.00",
                    "importe": 1,
                    "ds": "prueba 1pe",
                    "qty": 1
                },
            ],
            "setTrailer": [" ", "Mozo: Alejandra", "Mesa: 1", " "]
        }
    }

    t = TraductoresHandler()
    return t.json_to_comando(jsoncomando)
Пример #4
0
 def initialize(self):
     self.clients = []
     self.traductor = TraductoresHandler(self)
Пример #5
0
from threading import Timer
from Traductores.TraductoresHandler import TraductoresHandler, CONFIG_FILE_NAME, TraductorException
import ConfigParser

# chdir otherwise will not work fine in rc service
newpath = os.path.dirname(os.path.realpath(__file__))
os.chdir(newpath)

MAX_WAIT_SECONDS_BEFORE_SHUTDOWN = 2
INTERVALO_IMPRESORA_WARNING = 30.0

#global para el listado de clientes conectados
clients = []
# leer los parametros de configuracion de la impresora fiscal
# en config.ini
traductor = TraductoresHandler()


class WebSocketException(Exception):
    pass


class WSHandler(tornado.websocket.WebSocketHandler):
    def open(self):
        global clients
        clients.append(self)
        print 'new connection'

    def on_message(self, message):
        global traductor
        print("----- - -- - - - ---")
Пример #6
0
 def initialize(self, ref_object):
     self.fbApp = ref_object
     self.clients = []
     self.traductor = TraductoresHandler(self, self.fbApp)
Пример #7
0
 def initialize(self):
     self.traductor = TraductoresHandler(self)
Пример #8
0
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 Traductores.TraductoresHandler import TraductoresHandler
from escpos import printer

if __name__ == '__main__':

    # IMPRESORA_FISCAL
    traductor = TraductoresHandler()
    print traductor.traductores
    jsoncoso = {"printerName": "IMPRESORA_FISCAL", "dailyClose": "x"}

    jsoncoso = {
        "printerName": "IMPRESORA_FISCAL",
        "printTicket": {
            "encabezado": {
                "tipo_cbte": "FA",
                "nro_doc": "30711054231",
                "domicilio_cliente": "Rua 76 km 34.5 Alagoas",
                "tipo_doc": "CUIT",
                "nombre_cliente": "PXA PRUEBA",
                "tipo_responsable": "RESPONSABLE_INSCRIPTO"
            },
            "items": [{