import pycomm
from pycomm import db, redisop, mongo


def getCurrentSource():
    conf = pycomm.getCache('conf')
    return conf['currentSource']


def getMongo():
    conf = pycomm.getCache('conf')
    mongoConf = conf['mongo']
    return mongo.DBMongo(mongoConf['host'], mongoConf['dbname'], mongoConf['user'], mongoConf['password'],
                         mongoConf['port'])


# 得到数据库配置
def getDB():
    conf = pycomm.getCache('conf')
    pConf = conf['pgsql']
    pdb = db.DB(pConf['host'], pConf['port'], pConf['user'], pConf['password'], pConf['dbname'], 'pgsql')
    return pdb


# 得到redis配置
def getRedis():
    conf = pycomm.getCache('conf')
    rConf = conf['redis']
    redisobj = redisop.RedisHelper(rConf['host'], rConf['port'], rConf['password'])
    redisConn = redisobj.getConn()
    return redisConn
