import datetime
import logging
import os
import yaml

SITE_hGYBzZ07l!hj5kAq81Eww = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PEM_PATH = os.path.join(SITE_hGYBzZ07l!hj5kAq81Eww, "bin", "runtime", "pem", "")
apo = yaml.safe_load(open(PEM_PATH + "apollo.yaml", encoding='utf-8'))


class EnvPublic(object):
    """公共参数"""
    SITE_hGYBzZ07l!hj5kAq81Eww = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    SQLALCHEMY_DATABASE_URI = apo.get("SQLAlchemy_db_uri")
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    SECRET_KEY = apo.get("secret_key")
    config_rabbit = apo.get("config_rabbit")
    LOG_NAME = apo.get("log_name")  # 主日志
    LOG_LEVEL = logging.DEBUG
    LOG_STDERR = False  # 输出到标准错误流
    LOG_PATH = os.path.join(SITE_hGYBzZ07l!hj5kAq81Eww, "bin", "runtime", "logs", "info", "")
    LOG_ERROR_PATH = os.path.join(SITE_hGYBzZ07l!hj5kAq81Eww, "bin", "runtime", "logs", "error", "")
    today_time = datetime.datetime.now().strftime('%m-%d')

    ROBOT_PASSWORD = str(apo.get("RobotPassword"))
    LONGGER_DATA = apo.get("longger_data")
    SCRIPT_DATA = apo.get("script_data")
    redis = apo.get("redis")
    SECRET = apo.get('secret_key')
    HEADER = apo.get('header')
    SIGATURE_KEY = apo.get('sig_key')


class EnvDev(EnvPublic):
    """测试环境"""
    # redis
    REDIS_HOST = EnvPublic.redis.get("host")
    REDIS_PORT = EnvPublic.redis.get("port")
    REDIS_DB = EnvPublic.redis.get("redis_db")
    REDIS_PWD = EnvPublic.redis.get("password")

    BUS_MYSQL = apo.get("business_mysql")
    BAC_MYSQL = apo.get("backstage_mysql")

    BUSINESS_URL = "https://api.bmiss3.zhubei.cn/"
    SCRIPT_URL = "http://43.138.132.9:5050/"


class EnvFormal(EnvPublic):
    """正式环境"""
    REDIS_HOST = EnvPublic.redis.get("host")
    REDIS_PORT = EnvPublic.redis.get("port")
    REDIS_DB = EnvPublic.redis.get("redis_db")
    REDIS_PWD = EnvPublic.redis.get("password")

    BUS_MYSQL = apo.get("business_mysql")
    BAC_MYSQL = apo.get("backstage_mysql")

    BUSINESS_URL = "https://api.new.fjkankan.com/"
    SCRIPT_URL = "http://159.75.254.122:5050/"


env = EnvDev()
# env = EnvFormal()
