Exemplo n.º 1
0
    def recibir_datospersonales(self, data):
        """
        Recibe los datos de las autoridades de mesa del frontend y genera
        una lista de instancias Autoridad para pasar al ModuloRecuento
        """
        autoridades = []
        for autoridad in data['autoridades']:
            # funciona para Autoridad = Apellido, Nombre, TipoDoc,
            # NroDoc
            if len(autoridad) == 4:
                largos = map(lambda x: len(x), autoridad)
                del largos[2]
                if largos != [0, 0, 0]:
                    autoridad_mesa = Autoridad(*autoridad)
                    autoridades.append(autoridad_mesa)

        horaIsNone = (data['hora']['horas'] is None
                      or data['hora']['minutos'] is None)
        if self.modulo == MODULO_APERTURA:
            if horaIsNone:
                data['hora'] = {'horas': 8, 'minutos': 0}
            self.parent.crear_objeto(autoridades, data['hora'])
        else:
            if horaIsNone:
                data['hora'] = {'horas': 18, 'minutos': 0}
            self.parent.guardar_datos_del_presidente(autoridades, data['hora'])
Exemplo n.º 2
0
    def imprimir_serializado(self, tipo_tag, tag, transpose, only_buffer=False,
                             extra_data=None):
        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(hd=True).render_image()

        image = image.convert('L')
        if transpose:
            image = image.transpose(Image.ROTATE_270)
        if only_buffer:
            self.parent.printer.register_load_buffer_compressed()
        else:
            self.parent.printer.register_print_finished()
        data = image.getdata()
        self.parent.printer.load_buffer_compressed(
            data, self.parent._free_page_mem,
            print_immediately=not only_buffer)
Exemplo n.º 3
0
    def imprimir_serializado(self,
                             tipo_tag,
                             tag,
                             transpose,
                             only_buffer=False,
                             extra_data=None):
        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(hd=True).render_image()

        image = image.convert('L')
        if transpose:
            image = image.transpose(Image.ROTATE_270)
        if only_buffer:
            self.parent.printer.register_load_buffer_compressed()
        else:
            self.parent.printer.register_print_finished()
        data = image.getdata()
        self.parent.printer.load_buffer_compressed(
            data,
            self.parent._free_page_mem,
            print_immediately=not only_buffer)
Exemplo n.º 4
0
def run(args):
    printer = obtener_impresora()
    if args.serialized is None or not args.serialized:
        logger.debug("Corriendo proceso de impresion o cache de impresion")
        logger.debug(args)
        image_file = open(args.filepath)
        data = image_file.read()
        size = [int(num) for num in args.size.split(",")]
        dpi = tuple([int(num) for num in args.dpi.split(",")])
        image = Image.fromstring(args.mode, size, data)
        printer.imprimir_image(image, dpi, args.transpose, args.compress,
                               args.only_buffer)
    else:
        extra_data = loads(b64decode(args.extra_data))
        if args.tipo_tag == "Seleccion":
            boleta = Seleccion.desde_string(args.tag)
            image = boleta.a_imagen()
            dpi = get_dpi_boletas()
        elif args.tipo_tag == "Apertura":
            boleta = Apertura.desde_tag(b64decode(args.tag))
            autoridades = boleta.autoridades
            image = boleta.a_imagen()
            dpi = DPI_VOTO_ALTA if IMPRESION_HD_APERTURA else DPI_VOTO_BAJA
        elif args.tipo_tag == "Recuento":
            boleta = Recuento.desde_tag(b64decode(args.tag))
            autoridades = extra_data.get('autoridades')
            if autoridades is not None:
                for autoridad in autoridades:
                    boleta.autoridades.append(Autoridad.desde_dict(autoridad))
            boleta.hora = extra_data['hora']
            image = boleta.a_imagen(extra_data['tipo_acta'])
            dpi = DPI_VOTO_ALTA if IMPRESION_HD_CIERRE else DPI_VOTO_BAJA
        elif args.tipo_tag == "Prueba":
            dpi = DPI_VOTO_ALTA
            image = ImagenPrueba(hd=True).render_image()

    printer.imprimir_image(image, dpi, args.transpose, args.compress,
                           args.only_buffer)