예제 #1
0
 def _sendCommand(self, comando, skipStatusErrors=False):
     try:
         ret = self.conector.sendCommand(comando, skipStatusErrors)
         return ret
     except PrinterException, e:
         logging.getLogger().error("PrinterException: %s" % str(e))
         raise ComandoException("Error de la impresora: %s.\nComando enviado: %s" % \
                                (str(e), commandString))
예제 #2
0
 def _sendCommand(self, commandNumber, parameters, skipStatusErrors=False):
     print "_sendCommand", commandNumber, parameters
     try:
         logging.getLogger().info("sendCommand: SEND|0x%x|%s|%s" % (commandNumber,
                                                                    skipStatusErrors and "T" or "F",
                                                                    str(parameters)))
         return self.conector.sendCommand(commandNumber, parameters, skipStatusErrors)
     except PrinterException, e:
         logging.getLogger().error("PrinterException: %s" % str(e))
         raise ComandoException("Error de la impresora fiscal: " + str(e))
예제 #3
0
    def _sendCommand(self, commandNumber, parameters=(), skipStatusErrors=False):
        try:
            commandString = "SEND|0x%x|%s|%s" % (commandNumber, skipStatusErrors and "T" or "F",
                                                 str(parameters))
            logger.debug("-> sendCommand: %s" % commandString)

            ret = self.conector.sendCommand(commandNumber, parameters, skipStatusErrors)
            logger.debug("<- sendCommand reply: %s" % ret)
            return ret
        except PrinterException, e:
            logger.exception("PrinterException: %s" % str(e))
            raise ComandoException("Error de la impresora fiscal: %s.\nComando enviado: %s" %
                                   (str(e), commandString))
예제 #4
0
    def openNonFiscalReceipt(self):
        status = self._sendCommand(self.CMD_OPEN_NON_FISCAL_RECEIPT, [])

        def checkStatusInComprobante(x):
            fiscalStatus = int(x, 16)
            return (fiscalStatus & (1 << 13)) == (1 << 13)

        if not checkStatusInComprobante(status[1]):
            # No tom� el comando, el status fiscal dice que no hay comprobante abierto, intento de nuevo
            status = self._sendCommand(self.CMD_OPEN_NON_FISCAL_RECEIPT, [])
            if not checkStatusInComprobante(status[1]):
                raise ComandoException("Error de la impresora fiscal, no acepta el comando de iniciar "
                                       "un ticket no fiscal")

        self._currentDocument = self.CURRENT_DOC_NON_FISCAL
        return status