Exemplo n.º 1
0
 def __init__(self):
     if CFLogger.loggers is None:
         self.logger = None
         CFLogger.loggers = dict()
         self.__init_logger(CFAppConfig().get_app_name())
         # logging.basicConfig()
         self.__init_logger('sqlalchemy')
Exemplo n.º 2
0
    def exec_proc(self, name, param=None, refcursors=False):
        """
        @summary: Execute the query and fetch all result sets
        @param name: Name of the stored procedure or function to be executed
        @param param: Optional parameters, conditional list values (tuples)/List)
        @param refcursors: Optional parameters, indicates the presence of named cursors to retrieve resultset(s)
        @return: resultsets list of list(Dictionary model)/list(Dictionary model)/boolean Queried result sets
        """

        db_schema = CFAppConfig().get_bot_db_schema()
        name_w_schema = db_schema + COStringLiteral.STR_SEPARATOR_DOT + name
        sql = "Call " + name_w_schema
        if param is None:
            self._cursor.execute(sql)
        else:
            self._cursor.execute(sql, param)
        resultsets = dict()
        count = self._cursor.rowcount
        if count > 0:
            res = self._cursor.fetchall()
            if refcursors:
                named_cursors = res
                for named_cursor in named_cursors:
                    self._cursor.execute('FETCH ALL IN "' + named_cursor[0] +
                                         '"')
                    resultset = self._cursor.fetchall()
                    resultsets[named_cursor[0]] = resultset
            else:
                resultsets[0] = res
        return resultsets
Exemplo n.º 3
0
 def __init_logger(self, name):
     try:
         # create logger with name
         self.logger = logging.getLogger(name)
         self.logger.setLevel(CFAppConfig().get_log_level())
         # create file handler which logs even debug messages
         fh = logging.FileHandler(CFAppConfig().get_log_filename())
         fh.setLevel(CFAppConfig().get_log_level())
         # create console handler with a higher log level
         ch = logging.StreamHandler()
         ch.setLevel(CFAppConfig().get_log_level())
         # create formatter and add it to the handlers
         formatter = logging.Formatter(COAppLiteral.APP_CONFIG_LOG_FORMAT)
         fh.setFormatter(formatter)
         ch.setFormatter(formatter)
         # add the handlers to the logger
         self.logger.addHandler(fh)
         self.logger.addHandler(ch)
         CFLogger.loggers[name] = self.logger
     except:
         message = COMessageLiteral.MSG_LOGGER_INIT_FAILED
         print(Exception(message), message)
Exemplo n.º 4
0
    def __init__(self):
        if FWDBSession.__engine is None:
            config = CFAppConfig()
            conn_string = 'mysql://' + \
                          config.get_entity_db_user() + ':' + \
                          config.get_entity_db_password() + '@' + \
                          config.get_entity_db_host() + ':' + \
                          config.get_entity_db_port() + '/' + \
                          config.get_entity_db_name()
            # conn_string = 'mysql://*****:*****@3.12.207.166:3306/db_byonic'

            FWDBSession.__engine = create_engine(
                conn_string,
                echo=True,
                pool_size=int(CFAppConfig().get_pool_size()),
                max_overflow=0,
                poolclass=QueuePool)
Exemplo n.º 5
0
    def __getconn():
        """
        @summary: Static method to retrieve connection from connection pool
        @return FWDBConnection.connection
        """
        if FWDBConnection.__pool is None:
            # read connection parameters
            config = CFAppConfig()
            params = dict()
            params[CODBLiteral.DB_PARAM_HOST] = config.get_bot_db_host()
            params[CODBLiteral.DB_PARAM_PORT] = config.get_bot_db_port()
            params[CODBLiteral.DB_PARAM_DATABASE] = config.get_bot_db_name()
            params[CODBLiteral.DB_PARAM_USER] = config.get_bot_db_user()
            params[
                CODBLiteral.DB_PARAM_PASSWORD] = config.get_bot_db_password()

            FWDBConnection.__pool = SimpleConnectionPool(
                minconn=1, maxconn=5, cursor_factory=DictCursor, **params)
        return FWDBConnection.__pool.getconn()
Exemplo n.º 6
0
from scripts import login as logincheck
from scripts import companyCard as companyCard
from scripts.resetpassword import resetPassword
from byonic_aibm.usermanagement.user_role.rs_user_role import *
from byonic_aibm.domain_filtering import da_domain_filtering
from byonic_aibm.side_filters import bl_side_filters
from byonic_core.fw_config import CFAppConfig
from byonic_core.fw_auth import HTTPBasicAuth
from byonic_aibm.side_filters.country.rs_country import *
from byonic_aibm.side_filters.intent_topics.rs_intent_topics import *
from byonic_aibm.side_filters.job_levels.rs_job_level import *
from byonic_aibm.side_filters.employee_size.rs_employee_size import *
from byonic_aibm.side_filters.industry.rs_industry import *
from byonic_aibm.side_filters.revenue_range.rs_revenue_range import *

config = CFAppConfig()
auth = HTTPBasicAuth()

APP = Flask(config.get_aibm_api_name())
cors = CORS(APP, resources={r"/api/*": {"origins": "*"}})
APP.config['CORS_HEADERS'] = 'Content-Type'
r = redis.StrictRedis(host='localhost', port=6379, db=0)

global database, config_file, data_path, topic_json_path, configuration_file
global industry_json_path, country_json_path, job_json_path, cwd
global emp_size_path, CURRENT_WORKING_DIR, debug_mode, intent_request
global req_country, req_job, req_employee, req_topic, req_industry, req_jobtitle, req_revenue, req_domainEx, req_domainIn
global filename, lastname, email_addr, password, id, role, status


def use_global_variables():
Exemplo n.º 7
0
 def __init__(self):
     super().__init__()
     CFCacheManager.__enabled = CFAppConfig().is_cache_enabled()