def conn(cls): logger = HenriqueLogger.func_level2logger(cls.conn, logging.DEBUG) host = HenriqueEnv.key2value(cls.Env.HOST) port = HenriqueEnv.key2value(cls.Env.PORT) user = HenriqueEnv.key2value(cls.Env.USER) password = HenriqueEnv.key2value(cls.Env.PASSWORD) dbname = HenriqueEnv.key2value(cls.Env.DBNAME) j_connect = { "host": host, "port": port, "user": user, "password": password, "dbname": dbname, } logger.debug({"j_connect": j_connect}) conn = psycopg2.connect(**j_connect) return conn
def xoxb_token(cls): logger = HenriqueLogger.func_level2logger(cls.xoxb_token, logging.DEBUG) key = "SLACK_HENRIQUE_BOT_USER_OAUTH_ACCESS_TOKEN" token = HenriqueEnv.key2value(key) logger.debug({ "key": key, "bool(token)": bool(token), "token is None": token is None, }) return token
def start_discord(): from henrique.main.singleton.env.henrique_env import HenriqueEnv from henrique.main.singleton.logger.henrique_logger import KhalaLogger logger = KhalaLogger.func_level2logger(start_discord, logging.DEBUG) logger.debug({"HenriqueEnv.env()": HenriqueEnv.env()}) HenriqueWarmer.warmup_all() # maybe update? # https://stackoverflow.com/a/50981577 client = DiscordClient.client() discord_token = HenriqueEnv.key2value("DISCORD_TOKEN") logger.debug({"discord_token": discord_token}) assert_true(discord_token) client.run(discord_token)
def db(cls): client = cls.client() dbname = HenriqueEnv.key2value(cls.Env.MONGO_DBNAME) return client[dbname]
def uri(cls): logger = HenriqueLogger.func_level2logger(cls.client, logging.DEBUG) uri = HenriqueEnv.key2value(cls.Env.MONGO_URI) # logger.debug({"uri": uri}) return uri
def filepath_privatekey(cls): # http://console.cloud.google.com/iam-admin/serviceaccounts/details/112472142364049649520 # return os.path.join(REPO_DIR, "henrique","env", "google", "api", "henrique-272420-c09c9b3e31ff.json") return HenriqueEnv.key2value("GOOGLEAPI_PRIVATEKEY_FILEPATH")