コード例 #1
0
ファイル: asistida.py プロジェクト: Charlyzzz/vot.ar
 def __init__(self, *args, **kwargs):
     ControllerVoto.__init__(self, *args, **kwargs)
     global _audio_player
     if _audio_player is None or not _audio_player.is_alive():
         _audio_player = WavPlayer()
         _audio_player.start()
         _audio_player.set_volume(VOLUMEN_GENERAL)
コード例 #2
0
ファイル: asistida.py プロジェクト: sunzu/vot.ar
 def __init__(self, *args, **kwargs):
     ControllerVoto.__init__(self, *args, **kwargs)
     global _audio_player
     if _audio_player is None or not _audio_player.is_alive():
         _audio_player = WavPlayer()
         _audio_player.start()
         _audio_player.set_volume(VOLUMEN_GENERAL)
コード例 #3
0
ファイル: demo.py プロジェクト: sunzu/vot.ar
 def _iniciar_demo(self):
     self._descargar_ui_web()
     self.web_template = "voto"
     self.controller = ControllerVoto(self)
     self.registrador = FakeRegistrador(self._fin_registro, self.seleccion,
                                        self)
     self._cargar_ui_web()
     self.ventana.show_all()
コード例 #4
0
ファイル: demo.py プロジェクト: Charlyzzz/vot.ar
class ModuloDemo(ModuloVoto):

    def __init__(self):
        self._mesa_anterior = None
        self.controller = ControllerDemo(self)
        self.es_modulo_web = True
        self.web_template = "demo"

        Modulo.__init__(self)
        self.estado = None

        #self._limpiar_configuracion()
        self.volvera = None
        self._metiendo_papel = False
        self.momento_ultimo_voto = None
        self.constants_sent = False

        self.tiempo_verificacion = 5000

        self.rampa = RampaDemo(self)

    def _iniciar_demo(self):
        self._descargar_ui_web()
        self.web_template = "voto"
        self.controller = ControllerVoto(self)
        self.registrador = FakeRegistrador(self._fin_registro, self.seleccion,
                                           self)
        self._cargar_ui_web()
        self.ventana.show_all()

    def _ready(self):
        self.controller.send_constants()
        self.controller.cargar_botones()

    def _configurar_ubicacion_demo(self, tag, data=None):
        # Guardo una referencia a la configuracion anterior, para cuando salga
        # volver a configurarla
        #if self.pantalla:
        #    self.pantalla.callback = self.controlador
        #    self.pantalla.quit()
        mesa_obj = Ubicacion.one(numero=tag)
        self._mesa_anterior = sesion.mesa
        #self._configurar_mesa(mesa_obj)
        sesion.mesa = mesa_obj

    def salir(self):
        if self._mesa_anterior:
            #self._configurar_mesa(self._mesa_anterior)
            sesion.mesa = self._mesa_anterior
        sesion.impresora.expulsar_boleta()
        self.ret_code = MODULO_INICIO
        self.quit()
コード例 #5
0
ファイル: demo.py プロジェクト: sunzu/vot.ar
class ModuloDemo(ModuloVoto):
    def __init__(self):
        self._mesa_anterior = None
        self.controller = ControllerDemo(self)
        self.es_modulo_web = True
        self.web_template = "demo"

        Modulo.__init__(self)
        self.estado = None

        #self._limpiar_configuracion()
        self.volvera = None
        self._metiendo_papel = False
        self.momento_ultimo_voto = None
        self.constants_sent = False

        self.tiempo_verificacion = 5000

        self.rampa = RampaDemo(self)

    def _iniciar_demo(self):
        self._descargar_ui_web()
        self.web_template = "voto"
        self.controller = ControllerVoto(self)
        self.registrador = FakeRegistrador(self._fin_registro, self.seleccion,
                                           self)
        self._cargar_ui_web()
        self.ventana.show_all()

    def _ready(self):
        self.controller.send_constants()
        self.controller.cargar_botones()

    def _configurar_ubicacion_demo(self, tag, data=None):
        # Guardo una referencia a la configuracion anterior, para cuando salga
        # volver a configurarla
        #if self.pantalla:
        #    self.pantalla.callback = self.controlador
        #    self.pantalla.quit()
        mesa_obj = Ubicacion.one(numero=tag)
        self._mesa_anterior = sesion.mesa
        #self._configurar_mesa(mesa_obj)
        sesion.mesa = mesa_obj

    def salir(self):
        if self._mesa_anterior:
            #self._configurar_mesa(self._mesa_anterior)
            sesion.mesa = self._mesa_anterior
        sesion.impresora.expulsar_boleta()
        self.ret_code = MODULO_INICIO
        self.quit()
コード例 #6
0
ファイル: demo.py プロジェクト: Charlyzzz/vot.ar
 def _iniciar_demo(self):
     self._descargar_ui_web()
     self.web_template = "voto"
     self.controller = ControllerVoto(self)
     self.registrador = FakeRegistrador(self._fin_registro, self.seleccion,
                                        self)
     self._cargar_ui_web()
     self.ventana.show_all()
コード例 #7
0
ファイル: asistida.py プロジェクト: Charlyzzz/vot.ar
    def send_command(self, command, data=None):
        """Intercepta los comandos que se envian a la interfaz.

        Hace un override del metodo send_command de Zaguan para poder inyectar
        las cosas de asistidas del medio, tiene una lista de comandos para
        interceptar y una white_list de que comandos tiene que dejar pasar. El
        resto de los comandos no se envia nunca al front end.

        Argumentos:
            command -- El comando enviado originalmente al front end.
            data -- los datos que se mandaron como parametro al comando.
        """
        white_list = ["set_constants", "cargar_categorias",
                      "limpiar_data_categorias", "change_screen",
                      "insertando_boleta", "mostrar_voto",
                      "hide_barra_opciones", "imagen_consulta",
                      "mostrar_teclado", "cargar_adhesiones",
                      "cargar_consulta_popular", "mostrar_loader",
                      "ocultar_loader"]
        interceptar = {
            "pantalla_modos": [AsistenteModos, None],
            "cargar_listas": [AsistenteListaCompleta, None],
            "cargar_listas_params": [AsistenteListaCompleta, 0],
            "cargar_adhesiones": [AsistenteAdhesion, 0],
            "cargar_consulta_popular": [AsistenteConsultaPopular, 0],
            "cargar_candidatos": [AsistenteCandidatos, "candidatos"],
            "mostrar_confirmacion": [AsistenteConfirmacion, None],
            "seleccion_partido": [AsistentePartido, None],
        }

        if command in white_list:
            if command == "change_screen":
                attr = "change_screen_%s" % data[0]
                if hasattr(self, attr):
                    getattr(self, attr)()
            ControllerVoto.send_command(self, command, data)

        if command in interceptar.keys():
            clase, key = interceptar[command]
            self.asistente = clase(self, data, key)
            self.cambiar_monitor()
            self.send_command("mostrar_teclado")
コード例 #8
0
ファイル: asistida.py プロジェクト: sunzu/vot.ar
    def send_command(self, command, data=None):
        """Intercepta los comandos que se envian a la interfaz.

        Hace un override del metodo send_command de Zaguan para poder inyectar
        las cosas de asistidas del medio, tiene una lista de comandos para
        interceptar y una white_list de que comandos tiene que dejar pasar. El
        resto de los comandos no se envia nunca al front end.

        Argumentos:
            command -- El comando enviado originalmente al front end.
            data -- los datos que se mandaron como parametro al comando.
        """
        white_list = [
            "set_constants", "cargar_categorias", "limpiar_data_categorias",
            "change_screen", "insertando_boleta", "mostrar_voto",
            "hide_barra_opciones", "imagen_consulta", "mostrar_teclado",
            "cargar_adhesiones", "cargar_consulta_popular", "mostrar_loader",
            "ocultar_loader"
        ]
        interceptar = {
            "pantalla_modos": [AsistenteModos, None],
            "cargar_listas": [AsistenteListaCompleta, None],
            "cargar_listas_params": [AsistenteListaCompleta, 0],
            "cargar_adhesiones": [AsistenteAdhesion, 0],
            "cargar_consulta_popular": [AsistenteConsultaPopular, 0],
            "cargar_candidatos": [AsistenteCandidatos, "candidatos"],
            "mostrar_confirmacion": [AsistenteConfirmacion, None],
            "seleccion_partido": [AsistentePartido, None],
        }

        if command in white_list:
            if command == "change_screen":
                attr = "change_screen_%s" % data[0]
                if hasattr(self, attr):
                    getattr(self, attr)()
            ControllerVoto.send_command(self, command, data)

        if command in interceptar.keys():
            clase, key = interceptar[command]
            self.asistente = clase(self, data, key)
            self.cambiar_monitor()
            self.send_command("mostrar_teclado")
コード例 #9
0
ファイル: demo.py プロジェクト: Charlyzzz/vot.ar
    def __init__(self):
        self._mesa_anterior = None
        self.controller = ControllerDemo(self)
        self.es_modulo_web = True
        self.web_template = "demo"

        Modulo.__init__(self)
        self.estado = None

        #self._limpiar_configuracion()
        self.volvera = None
        self._metiendo_papel = False
        self.momento_ultimo_voto = None
        self.constants_sent = False

        self.tiempo_verificacion = 5000

        self.rampa = RampaDemo(self)
コード例 #10
0
ファイル: demo.py プロジェクト: sunzu/vot.ar
    def __init__(self):
        self._mesa_anterior = None
        self.controller = ControllerDemo(self)
        self.es_modulo_web = True
        self.web_template = "demo"

        Modulo.__init__(self)
        self.estado = None

        #self._limpiar_configuracion()
        self.volvera = None
        self._metiendo_papel = False
        self.momento_ultimo_voto = None
        self.constants_sent = False

        self.tiempo_verificacion = 5000

        self.rampa = RampaDemo(self)
コード例 #11
0
ファイル: asistida.py プロジェクト: Charlyzzz/vot.ar
 def cambiar_monitor(self):
     """Cambia el texto del monitor al del asistente actual."""
     ControllerVoto.send_command(self, "cambiar_indicador_asistida",
                                 self.asistente.get_monitor())
コード例 #12
0
ファイル: asistida.py プロジェクト: sunzu/vot.ar
 def cambiar_monitor(self):
     """Cambia el texto del monitor al del asistente actual."""
     ControllerVoto.send_command(self, "cambiar_indicador_asistida",
                                 self.asistente.get_monitor())
コード例 #13
0
ファイル: voto.py プロジェクト: Charlyzzz/vot.ar
 def set_controller(self):
     self.controller = ControllerVoto(self)
コード例 #14
0
ファイル: voto.py プロジェクト: Charlyzzz/vot.ar
class ModuloVoto(Modulo):

    """
        Modulo de voto.

        Hereda de: ModuloLector

        Espera a que se aproxime un tag, si esta vacio permite votar, sino
        muestra el contenido del tag.

        Si durante cualquier momento del voto, se retira el tag, cancela
        la operacion y vuelve a la pantalla de inicio.
    """

    def __init__(self):
        """Constructor"""
        if LOG_CAPTURE_STDOUT:
            import sys
            from logging import INFO, ERROR
            from msa import StreamToLogger
            sys.stdout = StreamToLogger(sesion.logger, INFO)
            sys.stderr = StreamToLogger(sesion.logger, ERROR)
        self.constants_sent = False
        self.send_function = None
        self.set_controller()
        self.es_modulo_web = True
        self.web_template = "voto"
        Modulo.__init__(self)
        self.estado = None

        self.ret_code = MODULO_VOTO
        self.volvera = None
        self._metiendo_papel = False
        self.momento_ultimo_voto = None

        self.registrador = Registrador(self._fin_registro,
                                       self.seleccion, self)
        self.sesion = sesion
        self.tiempo_verificacion = 5000

        self.rampa = RampaVoto(self)

    def set_estado(self, estado):
        """
            Setea el estado y realiza el seteo del tiempo para poder *medir* la
            espera
        """
        self.estado = estado

    def set_controller(self):
        self.controller = ControllerVoto(self)

    def _comenzar(self):
        # Inicializo la seleccion
        if self.estado != E_VOTANDO:
            self.set_estado(E_VOTANDO)
            self.seleccion = Seleccion(sesion.mesa, sesion.interna)
            self.controller.set_screen(PANTALLA_SELECCION_CANDIDATOS)

    def set_pantalla(self, pantalla, image_data=None):
        self.controller.set_screen(pantalla, image_data=image_data)

    def get_pantalla_inicial_voto(self):
        if SELECCIONAR_IDIOMA:
            self.controller.set_pantalla_idiomas()
        else:
            self.controller.get_pantalla_modos()

    def expulsar_boleta(self):
        self.rampa.tiene_papel = False
        self.set_estado(E_EXPULSANDO_BOLETA)
        self.expulsar_boleta()

    def salir(self):
        # Llamo al destroy para que elimine los pixbufs y evitar leaks
        if self.pantalla is not None:
            self.pantalla.destroy()

        if self.browser is not None:
            self.ventana.remove(self.browser)
        self.admin()

    def _fin_registro(self):
        self.set_pantalla(PANTALLA_MENSAJE_FINAL)

        def _retornar():
            if self.estado not in (E_CONSULTANDO, E_VOTANDO):
                self.pantalla_insercion()

        gobject.timeout_add(5000, _retornar)

    def _guardar_voto(self):
        self.set_estado(E_REGISTRANDO)
        if USA_ARMVE:
            self.registrador._registrar_voto()
            self.rampa.datos_tag = None
        else:
            self.registrador._proceso()
        self.momento_ultimo_voto = datetime.now()

    def pantalla_insercion(self):
        self.seleccion = None
        self.set_estado(E_ESPERANDO)
        self.set_pantalla(PANTALLA_INSERCION_BOLETA)

    def hay_tag_vacio(self):
        self._comenzar()

    def _consultar(self, datos_tag, force=False):
        if self.estado != E_CONSULTANDO or force:
            self.set_estado(E_CONSULTANDO)

            if datos_tag is not None and len(datos_tag) > 0:
                def _fin():
                    if self.estado == E_CONSULTANDO:
                        sigue = False
                        if self.rampa.tiene_papel:
                            self.rampa.expulsar_boleta()
                        else:
                            tag = sesion.lector.get_tag()
                            if tag is not None:
                                sigue = True
                                self._consultar(tag['datos'], True)
                        if not sigue:
                            # reseteo el estado del tag por si no me llega el evento.
                            self.rampa.datos_tag = None
                            self.pantalla_insercion()

                seleccion_tag = None
                try:
                    seleccion_tag = Seleccion.desde_tag(datos_tag, sesion.mesa)
                except Exception as e:
                    sesion.logger.error("La boleta no contiene datos validos")
                    sesion.logger.exception(e)
                    _fin()
                if seleccion_tag is not None:
                    self.controller.consulta(seleccion_tag)
                    gobject.timeout_add(self.tiempo_verificacion, _fin)
            else:
                self.rampa.expulsar_boleta()

    def document_ready(self):
        self.controller.send_constants()
        self.rampa.maestro()

    def show_dialogo(self, mensaje=None, callback_cancelar=None,
                     callback_aceptar=None, btn_cancelar=None,
                     btn_aceptar=None):
        self.controller.show_dialogo(mensaje, callback_cancelar,
                                     callback_aceptar, btn_cancelar,
                                     btn_aceptar)

    def hide_dialogo(self):
        self.controller.hide_dialogo()
コード例 #15
0
ファイル: voto.py プロジェクト: sunzu/vot.ar
 def set_controller(self):
     self.controller = ControllerVoto(self)
コード例 #16
0
ファイル: voto.py プロジェクト: sunzu/vot.ar
class ModuloVoto(Modulo):
    """
        Modulo de voto.

        Hereda de: ModuloLector

        Espera a que se aproxime un tag, si esta vacio permite votar, sino
        muestra el contenido del tag.

        Si durante cualquier momento del voto, se retira el tag, cancela
        la operacion y vuelve a la pantalla de inicio.
    """
    def __init__(self):
        """Constructor"""
        if LOG_CAPTURE_STDOUT:
            import sys
            from logging import INFO, ERROR
            from msa import StreamToLogger
            sys.stdout = StreamToLogger(sesion.logger, INFO)
            sys.stderr = StreamToLogger(sesion.logger, ERROR)
        self.constants_sent = False
        self.send_function = None
        self.set_controller()
        self.es_modulo_web = True
        self.web_template = "voto"
        Modulo.__init__(self)
        self.estado = None

        self.ret_code = MODULO_VOTO
        self.volvera = None
        self._metiendo_papel = False
        self.momento_ultimo_voto = None

        self.registrador = Registrador(self._fin_registro, self.seleccion,
                                       self)
        self.sesion = sesion
        self.tiempo_verificacion = 5000

        self.rampa = RampaVoto(self)

    def set_estado(self, estado):
        """
            Setea el estado y realiza el seteo del tiempo para poder *medir* la
            espera
        """
        self.estado = estado

    def set_controller(self):
        self.controller = ControllerVoto(self)

    def _comenzar(self):
        # Inicializo la seleccion
        if self.estado != E_VOTANDO:
            self.set_estado(E_VOTANDO)
            self.seleccion = Seleccion(sesion.mesa, sesion.interna)
            self.controller.set_screen(PANTALLA_SELECCION_CANDIDATOS)

    def set_pantalla(self, pantalla, image_data=None):
        self.controller.set_screen(pantalla, image_data=image_data)

    def get_pantalla_inicial_voto(self):
        if SELECCIONAR_IDIOMA:
            self.controller.set_pantalla_idiomas()
        else:
            self.controller.get_pantalla_modos()

    def expulsar_boleta(self):
        self.rampa.tiene_papel = False
        self.set_estado(E_EXPULSANDO_BOLETA)
        self.expulsar_boleta()

    def salir(self):
        # Llamo al destroy para que elimine los pixbufs y evitar leaks
        if self.pantalla is not None:
            self.pantalla.destroy()

        if self.browser is not None:
            self.ventana.remove(self.browser)
        self.admin()

    def _fin_registro(self):
        self.set_pantalla(PANTALLA_MENSAJE_FINAL)

        def _retornar():
            if self.estado not in (E_CONSULTANDO, E_VOTANDO):
                self.pantalla_insercion()

        gobject.timeout_add(5000, _retornar)

    def _guardar_voto(self):
        self.set_estado(E_REGISTRANDO)
        if USA_ARMVE:
            self.registrador._registrar_voto()
            self.rampa.datos_tag = None
        else:
            self.registrador._proceso()
        self.momento_ultimo_voto = datetime.now()

    def pantalla_insercion(self):
        self.seleccion = None
        self.set_estado(E_ESPERANDO)
        self.set_pantalla(PANTALLA_INSERCION_BOLETA)

    def hay_tag_vacio(self):
        self._comenzar()

    def _consultar(self, datos_tag, force=False):
        if self.estado != E_CONSULTANDO or force:
            self.set_estado(E_CONSULTANDO)

            if datos_tag is not None and len(datos_tag) > 0:

                def _fin():
                    if self.estado == E_CONSULTANDO:
                        sigue = False
                        if self.rampa.tiene_papel:
                            self.rampa.expulsar_boleta()
                        else:
                            tag = sesion.lector.get_tag()
                            if tag is not None:
                                sigue = True
                                self._consultar(tag['datos'], True)
                        if not sigue:
                            # reseteo el estado del tag por si no me llega el evento.
                            self.rampa.datos_tag = None
                            self.pantalla_insercion()

                seleccion_tag = None
                try:
                    seleccion_tag = Seleccion.desde_tag(datos_tag, sesion.mesa)
                except Exception as e:
                    sesion.logger.error("La boleta no contiene datos validos")
                    sesion.logger.exception(e)
                    _fin()
                if seleccion_tag is not None:
                    self.controller.consulta(seleccion_tag)
                    gobject.timeout_add(self.tiempo_verificacion, _fin)
            else:
                self.rampa.expulsar_boleta()

    def document_ready(self):
        self.controller.send_constants()
        self.rampa.maestro()

    def show_dialogo(self,
                     mensaje=None,
                     callback_cancelar=None,
                     callback_aceptar=None,
                     btn_cancelar=None,
                     btn_aceptar=None):
        self.controller.show_dialogo(mensaje, callback_cancelar,
                                     callback_aceptar, btn_cancelar,
                                     btn_aceptar)

    def hide_dialogo(self):
        self.controller.hide_dialogo()