Beispiel #1
0
def set_config_dir():
    home = os.getenv("HOME")
    data_folder = join(home, SETTINGS_FOLDER)
    if not exists(data_folder):
        mkdir(data_folder)

    set_data_source(data_folder)
Beispiel #2
0
 def _verificar_datos(self):
     # @TODO: Verificar si los datos que posee el cliente son válidos
     # encontrar un método para verificar esto
     msg = ''
     destino = '/tmp/datos_actualizados'
     destino_tmp = '/tmp'
     version_datos = ConfiguracionSistema.one(codigo='db_version').valor
     logger.debug('Verificando datos locales: {}'.format(version_datos))
     respuesta = self._conexion.obtener_datos_servidor(version_datos)
     logger.debug('Verificando datos remotos: {}'.format(
         respuesta['version']))
     if len(respuesta['archivo']) > 0:
         actualizar_datos(respuesta['ubicacion'], respuesta['archivo'],
                          destino, destino_tmp)
         # Borro la cache del objeto configuracion
         cache_name = ConfiguracionSistema.get_cache_name()
         if cache_name is not None and hasattr(ConfiguracionSistema.cache,
                                               cache_name):
             ConfiguracionSistema.cache.clear(cache_name)
         # Defino un nuevo origen de datos
         set_data_source(destino)
     else:
         msg = 'no '
     logger.debug("Funcion: obtener datos del servidor, "
                  "Los datos para la ubicación {} {}han sido "
                  "actualizados".format(respuesta['ubicacion'], msg))
Beispiel #3
0
 def _validar_datos(self):
     # @TODO: Verificar si los datos que posee el cliente son válidos
     # encontrar un método para verificar esto
     msg = ''
     destino = '/tmp/datos_actualizados'
     destino_tmp = '/tmp'
     version_datos = ConfiguracionSistema.one(codigo='db_version').valor
     self.logger.debug(
         'Verificando datos locales: {}'.format(version_datos))
     respuesta = self._conexion.obtener_datos_servidor(version_datos)
     self.logger.debug(
         'Verificando datos remotos: {}'.format(respuesta['version']))
     if len(respuesta['archivo']) > 0:
         actualizar_datos(respuesta['ubicacion'], respuesta['archivo'],
                          destino, destino_tmp)
         # Borro la cache del objeto configuracion
         cache_name = ConfiguracionSistema.get_cache_name()
         if cache_name is not None and hasattr(ConfiguracionSistema.cache,
                                               cache_name):
             ConfiguracionSistema.cache.clear(cache_name)
         # Defino un nuevo origen de datos
         set_data_source(destino)
     else:
         msg = 'no '
     self.logger.debug("Funcion: obtener datos del servidor, "
                       "Los datos para la ubicación {} {} han sido "
                       "actualizados".format(respuesta['ubicacion'], msg))
Beispiel #4
0
def set_config_dir():
    data_folder = os.path.join(HOMEDIR, ".touchandgo")
    if not exists(data_folder):
        mkdir(data_folder)

    set_data_source(data_folder)
Beispiel #5
0
def set_config_dir():
    data_folder = "%s/.touchandgo" % os.getenv("HOME")
    if not exists(data_folder):
        mkdir(data_folder)

    set_data_source(data_folder)
Beispiel #6
0
# -*- coding: utf-8 -*-
from ojota import Ojota, set_data_source
from ojota.base import OjotaHierarchy

from msa.core.constants import COD_IMPRESION_BAJA
from msa.core.exceptions import TemplateNoEncontrado
from msa.core.data.settings import PATH_DATOS_JSON, NOMBRE_JSON_MESAS
from msa.core.settings import IMPRESION_HD_BOLETAS


set_data_source(PATH_DATOS_JSON)


class Ubicacion(OjotaHierarchy):

    """Ubicacion de votacion."""

    plural_name = NOMBRE_JSON_MESAS
    pk_field = "codigo"
    default_order = "codigo"
    required_fields = ("descripcion", "cod_datos", "clase")

    def templates_impresion(self, forzar_media=False):
        mejor_match = None
        for t in TemplateMap.all():
            if self.cod_datos.startswith(t.codigo):
                if not mejor_match or \
                   len(t.codigo) > len(mejor_match.codigo):
                    mejor_match = t
        # TODO: solucionar este lio de raiseo de excepciones y de return fuera
        # de lugar
Beispiel #7
0
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU  Lesser General Public License
    along with Ojota.  If not, see <http://www.gnu.org/licenses/>.
"""
from __future__ import absolute_import
import os

from ojota import Ojota, Relation, set_data_source, Callback
from ojota.base import OjotaHierarchy
from ojota.cache import Memcache
from ojota.examples.example_ws import Country, Flag
from ojota.sources import YAMLSource, CSVSource, XLSSource

file_path = (os.path.dirname(os.path.abspath(__file__)))
set_data_source(os.path.join(file_path, "data"))


class Team(Ojota):
    plural_name = "Teams"
    pk_field = "id"
    data_source = YAMLSource()
    required_fields = ("id", "name", "color")

    def __repr__(self):
        return self.name


class Person(Ojota):
    plural_name = "Persons"
    pk_field = "id"
Beispiel #8
0
def set_config_dir():
    data_folder = "%s/.pyflix" % os.getenv("HOME")
    if not exists(data_folder):
        mkdir(data_folder)

    set_data_source(data_folder)
Beispiel #9
0
 def test_data_source(self):
     """Testing the set_data_source function."""
     expected = "dir1/dir2"
     set_data_source(expected)
     result = sources._DATA_SOURCE
     self.assertEqual(expected, result)
Beispiel #10
0
# -*- coding: utf-8 -*-
import hashlib

from ojota import Ojota, set_data_source
from ojota.base import OjotaHierarchy

from msa.core.constants import COD_IMPRESION_BAJA
from msa.core.exceptions import TemplateNoEncontrado
from msa.core.data.settings import PATH_DATOS_JSON, NOMBRE_JSON_MESAS
from msa.core.settings import IMPRESION_HD_BOLETAS

set_data_source(PATH_DATOS_JSON)


class Ubicacion(OjotaHierarchy):
    """Ubicacion de votacion."""

    plural_name = NOMBRE_JSON_MESAS
    pk_field = "codigo"
    default_order = "codigo"
    required_fields = ("descripcion", "cod_datos", "clase")

    def templates_impresion(self, forzar_media=False):
        mejor_match = None
        for t in TemplateMap.all():
            if self.cod_datos.startswith(t.codigo):
                if not mejor_match or \
                   len(t.codigo) > len(mejor_match.codigo):
                    mejor_match = t
        # TODO: solucionar este lio de raiseo de excepciones y de return fuera
        # de lugar
Beispiel #11
0
def set_config_dir():
    data_folder = os.path.join(HOMEDIR, ".touchandgo")
    if not exists(data_folder):
        mkdir(data_folder)

    set_data_source(data_folder)