Beispiel #1
0
    def imprimir_serializado(self, tipo_tag, tag, transpose, only_buffer=False,
                             extra_data=None):
        """Registra un documento que fue enviado serializado via d-bus.

        Argumentos:
            tipo_tag -- el tipo de documento que queremos registrar. Puede ser:
                (Seleccion, Apertura, Recuento o Prueba)
            tag -- Contenido del tag serializado.
            transpose -- transpone la imagen.
            only_buffer -- Solo guarda en el buffer, no imprime.
            extra_data -- datos extra que queremos imprimir pero que no se
            guardan en el chip.
        """
        self._buffering = True
        if tipo_tag == "Seleccion":
            if type(tag) == Seleccion:
                boleta = tag
            else:
                boleta = Seleccion.desde_string(tag)
            image = boleta.a_imagen()
        elif tipo_tag == "Apertura":
            boleta = Apertura.desde_tag(b64decode(tag))
            image = boleta.a_imagen()
        elif tipo_tag == "Recuento":
            boleta = Recuento.desde_tag(b64decode(tag))
            extra_data = loads(extra_data)
            autoridades = extra_data.get('autoridades')
            if autoridades is not None and len(autoridades):
                boleta.autoridades = [Autoridad.desde_dict(aut) for aut
                                      in autoridades]
            boleta.hora = extra_data['hora']
            image = boleta.a_imagen(extra_data['tipo_acta'])
        elif tipo_tag == "Prueba":
            image = ImagenPrueba().render_image()

        image = image.convert('L')
        if transpose:
            image = image.transpose(Image.ROTATE_270)
        if only_buffer:
            if self.parent.impresion_v2:
                self.parent.printer.register_load_buffer_compressed_full()
            else:
                self.parent.printer.register_load_buffer_compressed()
        else:
            self.parent.printer.register_print_finished()
        data = image.getdata()
        if self.parent.impresion_v2:
            width, height = image.size
            self.parent.printer.load_buffer_compressed_full(
                data, self.parent._free_page_mem, width, height,
                print_immediately=not only_buffer)
        else:
            self.parent.printer.load_buffer_compressed(
                data, self.parent._free_page_mem,
                print_immediately=not only_buffer)
Beispiel #2
0
 def _inner():
     seleccion = Seleccion.desde_string(tag)
     self.imprimir_serializado("Seleccion", seleccion, True)
Beispiel #3
0
    def imprimir_serializado(self,
                             tipo_tag,
                             tag,
                             transpose,
                             only_buffer=False,
                             extra_data=None):
        """Registra un documento que fue enviado serializado via d-bus.

        Argumentos:
            tipo_tag -- el tipo de documento que queremos registrar. Puede ser:
                (Seleccion, Apertura, Recuento o Prueba)
            tag -- Contenido del tag serializado.
            transpose -- transpone la imagen.
            only_buffer -- Solo guarda en el buffer, no imprime.
            extra_data -- datos extra que queremos imprimir pero que no se
            guardan en el chip.
        """
        self._buffering = True
        if tipo_tag == "Seleccion":
            if type(tag) == Seleccion:
                boleta = tag
            else:
                boleta = Seleccion.desde_string(tag)
            image = boleta.a_imagen()
        elif tipo_tag == "Apertura":
            boleta = Apertura.desde_tag(b64decode(tag))
            image = boleta.a_imagen()
        elif tipo_tag == "Recuento":
            boleta = Recuento.desde_tag(b64decode(tag))
            extra_data = loads(extra_data)
            autoridades = extra_data.get('autoridades')
            if autoridades is not None and len(autoridades):
                boleta.autoridades = [
                    Autoridad.desde_dict(aut) for aut in autoridades
                ]
            boleta.hora = extra_data['hora']
            image = boleta.a_imagen(extra_data['tipo_acta'])
        elif tipo_tag == "Prueba":
            image = ImagenPrueba().render_image()

        image = image.convert('L')
        if transpose:
            image = image.transpose(Image.ROTATE_270)
        if only_buffer:
            if self.parent.impresion_v2:
                self.parent.printer.register_load_buffer_compressed_full()
            else:
                self.parent.printer.register_load_buffer_compressed()
        else:
            self.parent.printer.register_print_finished()
        data = image.getdata()
        if self.parent.impresion_v2:
            width, height = image.size
            self.parent.printer.load_buffer_compressed_full(
                data,
                self.parent._free_page_mem,
                width,
                height,
                print_immediately=not only_buffer)
        else:
            self.parent.printer.load_buffer_compressed(
                data,
                self.parent._free_page_mem,
                print_immediately=not only_buffer)
Beispiel #4
0
 def _inner():
     seleccion = Seleccion.desde_string(tag)
     self.imprimir_serializado("Seleccion", seleccion, True)