Пример #1
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)
Пример #2
0
 def cargar_apertura(self, tag_dict):
     apertura = Apertura.desde_tag(tag_dict['datos'])
     if (self.controller.estado == E_INGRESO_DATOS and
             sesion.mesa.numero == apertura.mesa.numero) or \
             self.controller.estado != E_INGRESO_DATOS:
         self.apertura = apertura
         self.controller.set_pantalla({"mesa": apertura.mesa.numero})
Пример #3
0
 def cargar_apertura(self, tag_dict):
     apertura = Apertura.desde_tag(tag_dict['datos'])
     if (self.controller.estado == E_INGRESO_DATOS and
             sesion.mesa.numero == apertura.mesa.numero) or \
             self.controller.estado != E_INGRESO_DATOS:
         self.apertura = apertura
         self.controller.set_pantalla({"mesa": apertura.mesa.numero})
Пример #4
0
 def _configurar_mesa(self, datos_tag):
     """
     Configura la mesa con los datos que contiene el tag.
     """
     apertura = Apertura.desde_tag(datos_tag)
     if apertura.mesa is not None:
         sesion.apertura = apertura
         sesion.mesa = apertura.mesa
         self.mesa_abierta = True
         self._inicio()
Пример #5
0
 def _configurar_mesa(self, datos_tag):
     """
     Configura la mesa con los datos que contiene el tag.
     """
     apertura = Apertura.desde_tag(datos_tag)
     if apertura.mesa is not None:
         sesion.apertura = apertura
         sesion.mesa = apertura.mesa
         sesion.impresora.expulsar_boleta()
         sesion.impresora.consultar_tarjeta(lambda x: self.salir())
Пример #6
0
 def _configurar_mesa(self, datos_tag):
     """
     Configura la mesa con los datos que contiene el tag.
     """
     apertura = Apertura.desde_tag(datos_tag)
     if apertura.mesa is not None:
         sesion.apertura = apertura
         sesion.mesa = apertura.mesa
         self.mesa_abierta = True
         self._inicio()
Пример #7
0
 def _configurar_mesa(self, datos_tag):
     """
     Configura la mesa con los datos que contiene el tag.
     """
     apertura = Apertura.desde_tag(datos_tag)
     if apertura.mesa is not None:
         sesion.apertura = apertura
         sesion.mesa = apertura.mesa
         sesion.impresora.expulsar_boleta()
         sesion.impresora.consultar_tarjeta(lambda x: self.salir())
Пример #8
0
 def _dump_check(self):
     """ Chequeo que el sistema no haya reiniciado previamente """
     if os.path.exists(DUMP_FILE_REINICIO):
         try:
             dump_file = open(DUMP_FILE_REINICIO, 'r')
             dump_data = cPickle.load(dump_file)
         except:
             pass
         else:
             apertura = Apertura.desde_tag(dump_data)
             if apertura.mesa is not None:
                 self._validar_configuracion(mesa=apertura.mesa.numero,
                                             pin=None,
                                             con_acta_apertura=True,
                                             datos_tag=dump_data)
         finally:
             dump_file.close()
             os.remove(DUMP_FILE_REINICIO)
     return False  # Se ejecuta una vez
Пример #9
0
    def _validar_configuracion(self, mesa=None, pin=None,
                               con_acta_apertura=False, datos_tag=''):
        """ Recibe el numero de mesa y el pin de la pantalla de configuración y
            verifica que sea correcto.
            Si es *con_acta_apertura* se carga la mesa automaticamente y con
            datos tag carga los datos del presidente
            Si es correcto configura la mesa para dejarla operativa y pasa al
            menú de administración, en otro caso presenta la pantalla
            principal.
        """
        mesa_obj = Ubicacion.one(numero=mesa)

        if mesa_obj is not None and \
                (pin is not None and
                 hashlib.sha1(pin).hexdigest() == mesa_obj.pin or
                 con_acta_apertura):
            self._mesa = mesa_obj
            # Le seteo el atributo abierta si la configuracion de la mesa fue
            # con el acta de apertura
            self._configurar_mesa()
            if con_acta_apertura:
                apertura = Apertura.desde_tag(datos_tag)
                sesion.apertura = apertura
            self.estado = E_CONFIGURADA
            self.ret_code = MODULO_ADMIN
            if self.rampa.tiene_papel:
                self.rampa.expulsar_boleta()
            gobject.idle_add(self.quit)
        else:
            if sesion.lector is None:
                msg = _("error_conectar_lector")
            else:
                msg = _("mesa_pin_incorrectos")
            mensaje = {"aclaracion": msg}

            self.estado = E_INICIAL
            self.ventana.remove(self.ventana.children()[0])
            self._cargar_ui_web()
            self.ventana.show_all()
            self._pantalla_principal()
            self.show_dialogo(mensaje, btn_aceptar=True)
Пример #10
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)
Пример #11
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)
Пример #12
0
 def abrir_mesa(self, datos_tag):
     apertura = Apertura.desde_tag(datos_tag)
     self._validar_configuracion(mesa=apertura.mesa.numero, pin=None,
                                 con_acta_apertura=True,
                                 datos_tag=datos_tag)