def convert_to_int(str_value):
    """
    Essa função foi criada para ser usada em loops funcionais z = [x for x in y]
    :param str_value:
    :return:
    :rtype: int
    """
    value = 0
    try:
        value = int(str_value)
    except Exception as err:
        get_logger().error(err)

    return value
 def __init__(self, logger=None, config=None):
     # logger
     self.logger = logger if logger is not None else get_logger()
     # configurations
     self.config = config if config is not None else get_config()
     # last_exception
     self.exception = None
 def __init__(self, logger=None, redis_connection=None):
     # logger
     self.logger = logger if logger is not None else get_logger()
     # database connection
     self.redis_connection = redis_connection if redis_connection is not None else get_connection()
     self.total = 0
     self.where = None
示例#4
0
 def __init__(self, logger=None):
     """
     # This cant import get_config
     :param logger:
     """
     # logger
     self.logger = logger if logger is not None else get_logger()
     # last_exception
     self.exception = None
def get_internal_logger():
    try:
        from flask_app.logging import get_logger
        logger = get_logger()
    except Exception as err:
        print('load_env: Unable to load logger: {}'.format(err))
        import logging
        log_name = APP_NAME
        logger = logging.getLogger(log_name)
    return logger
示例#6
0
def get_doc(fn):
    logger = get_logger()
    doc_yml = ''
    try:

        fn_doc = fn.__doc__
        fn_doc = fn_doc.split('---')[-1]
        doc_yml = yaml.safe_load(fn_doc)
    except Exception as err:
        logger.error(err)
    return doc_yml
示例#7
0
import os

from time import sleep

import redis

from flask_app.config import get_config
from flask_app.logging import get_logger

logger = get_logger()

_CONNECTION = False
_RETRY_COUNT = 0
_MAX_RETRY_ATTEMPTS = 3


def reset():
    global _CONNECTION
    _CONNECTION = False


def get_connection(config=None, retry=False):
    global _CONNECTION, _RETRY_COUNT, _MAX_RETRY_ATTEMPTS
    if not _CONNECTION:
        connection = None

        if config is None:
            config = get_config()

        try:
            host = config.REDIS_HOST