コード例 #1
0
ファイル: __init__.py プロジェクト: haoyiping/zvt
def init_env(zvt_home: str) -> None:
    """

    :param zvt_home: home path for zvt
    """
    data_path = os.path.join(zvt_home, 'data')
    if not os.path.exists(data_path):
        os.makedirs(data_path)

    init_data_env(data_path=data_path, domain_module='zvt.domain')

    zvt_env['zvt_home'] = zvt_home
    zvt_env['data_path'] = data_path
    zvt_env['domain_module'] = 'zvt.domain'

    # path for storing ui results
    zvt_env['ui_path'] = os.path.join(zvt_home, 'ui')
    if not os.path.exists(zvt_env['ui_path']):
        os.makedirs(zvt_env['ui_path'])

    # path for storing logs
    zvt_env['log_path'] = os.path.join(zvt_home, 'logs')
    if not os.path.exists(zvt_env['log_path']):
        os.makedirs(zvt_env['log_path'])

    # create default config.json if not exist
    config_path = os.path.join(zvt_home, 'config.json')
    if not os.path.exists(config_path):
        from shutil import copyfile
        copyfile(
            os.path.abspath(
                os.path.join(os.path.dirname(__file__), 'samples',
                             'config.json')), config_path)

    with open(config_path) as f:
        config_json = json.load(f)
        for k in config_json:
            zvt_env[k] = config_json[k]

    init_log()

    from zvt.domain import init_schema

    init_schema()
コード例 #2
0
def init_env(
    data_path: str,
    jq_username: str = os.environ.get('JQ_USERNAME'),
    jq_password: str = os.environ.get('JQ_PASSWORD')
) -> None:
    """

    :param data_path: data path for zvt
    :param jq_username: joinquant username
    :param jq_password: joinquant password
    """

    init_data_env(data_path=data_path, domain_module='zvt.domain')

    zvt_env['data_path'] = data_path
    zvt_env['domain_module'] = 'zvt.domain'

    # path for storing ui results
    zvt_env['ui_path'] = os.path.join(data_path, 'ui')
    if not os.path.exists(zvt_env['ui_path']):
        os.makedirs(zvt_env['ui_path'])

    # path for storing logs
    zvt_env['log_path'] = os.path.join(data_path, 'logs')
    if not os.path.exists(zvt_env['log_path']):
        os.makedirs(zvt_env['log_path'])

    # setting joinquant account
    zvt_env['jq_username'] = jq_username
    zvt_env['jq_password'] = jq_password

    init_log()

    from zvt.domain import init_schema

    init_schema()
コード例 #3
0
ファイル: __init__.py プロジェクト: zfsamzfsam/zvt
def init_log():
    root_logger = logging.getLogger()
    root_logger.setLevel(logging.INFO)

    fh = logging.FileHandler('zvt.log')
    fh.setLevel(logging.INFO)

    ch = logging.StreamHandler()
    ch.setLevel(logging.INFO)

    # create formatter and add it to the handlers
    formatter = logging.Formatter(
        "%(levelname)s  %(threadName)s  %(asctime)s  %(name)s:%(lineno)s  %(funcName)s  %(message)s"
    )
    fh.setFormatter(formatter)
    ch.setFormatter(formatter)

    # add the handlers to the logger
    root_logger.addHandler(fh)
    root_logger.addHandler(ch)

    logging.getLogger('sqlalchemy.engine').setLevel(logging.ERROR)
    logging.getLogger('sqlalchemy.dialects').setLevel(logging.ERROR)


pd.set_option('expand_frame_repr', False)

init_schema()
init_log()