Esempio n. 1
0
 def _populate_cached_data_dictionary():
     db_connection = Banco(os.path.join(".intpy", "intpy.db"))
     list_of_ipcache_files = db_connection.executarComandoSQLSelect("SELECT cache_file FROM CACHE")
     for ipcache_file in list_of_ipcache_files:
         ipcache_file = ipcache_file[0].replace(".ipcache", "")
         
         result = _deserialize(ipcache_file)
         if(result is None):
             continue
         else:
             with CACHED_DATA_DICTIONARY_SEMAPHORE:
                 DATA_DICTIONARY[ipcache_file] = result
     db_connection.fecharConexao()
Esempio n. 2
0
def create_entry(fun_name, fun_args, fun_return, fun_source, argsp_v):
    id = _get_id(fun_args, fun_source)
    if argsp_v == ['v01x']:
        global CONEXAO_BANCO
        CONEXAO_BANCO = Banco(os.path.join(".intpy", "intpy.db"))
        debug("serializing return value from {0}".format(id))
        _serialize(fun_return, id)
        debug("inserting reference in database")
        _save(_get_file_name(id))
        CONEXAO_BANCO.salvarAlteracoes()
        CONEXAO_BANCO.fecharConexao()

    elif (argsp_v == ['1d-ow'] or argsp_v == ['v021x'] or argsp_v == ['1d-ad']
          or argsp_v == ['v022x']):
        DATA_DICTIONARY[id] = fun_return
    elif (argsp_v == ['2d-ad'] or argsp_v == ['v023x']
          or argsp_v == ['2d-ad-t'] or argsp_v == ['v024x']
          or argsp_v == ['2d-lz'] or argsp_v == ['v027x']):
        NEW_DATA_DICTIONARY[id] = fun_return
    elif (argsp_v == ['2d-ad-f'] or argsp_v == ['v025x']
          or argsp_v == ['2d-ad-ft'] or argsp_v == ['v026x']):
        NEW_DATA_DICTIONARY[id] = (fun_return, fun_name)
Esempio n. 3
0
def _get_cache_data_v01x(id):
    global CONEXAO_BANCO
    CONEXAO_BANCO = Banco(os.path.join(".intpy", "intpy.db"))
    list_file_name = _get(_get_file_name(id))
    CONEXAO_BANCO.fecharConexao()
    return _deserialize(id) if len(list_file_name) == 1 else None
Esempio n. 4
0
import hashlib
import os
import threading

from intpy.parser_params import get_params
from intpy.banco import Banco
from intpy.logger.log import debug, warn

#from . import CONEXAO_BANCO

# Opening database connection and creating select query to the database
# to populate DATA_DICTIONARY
g_argsp_v, g_argsp_no_cache = get_params()
CONEXAO_BANCO = None
if (g_argsp_v != ['v01x']):
    CONEXAO_BANCO = Banco(os.path.join(".intpy", "intpy.db"))
DATA_DICTIONARY = {}
NEW_DATA_DICTIONARY = {}
FUNCTIONS_ALREADY_SELECTED_FROM_DB = []
CACHED_DATA_DICTIONARY_SEMAPHORE = threading.Semaphore()


def _save(file_name):
    CONEXAO_BANCO.executarComandoSQLSemRetorno(
        "INSERT OR IGNORE INTO CACHE(cache_file) VALUES (?)", (file_name, ))


#Versão desenvolvida por causa do _save em salvarNovosDadosBanco para a v0.2.5.x e a v0.2.6.x, com o nome da função
#Testar se existe a sobrecarga
def _save_fun_name(file_name, fun_name):
    CONEXAO_BANCO.executarComandoSQLSemRetorno(