Ejemplo n.º 1
0
def init(msg, import_id, uid_tid_lid):
    global mysql_pool, mongo_cn, fp_err_t1, fp_err_t2
    conf = pyetc.load(os.path.join(ROOT, 'conf', 'setting.conf'))

    # 获取数据库
    dbconf = {'mysql': conf.mysql, 'mongo': conf.mongo}

    try:
        mysql_pool = MysqlPool.Mysql(dbconf, log)
    except BaseException as e:
        log.error(u'{}. init mysql pool exception.'.format(msg))
        log.error(traceback.format_exc())
        do_except(uid_tid_lid)

    try:
        mongo_cn = MongoPool.Mongo(dbconf, log)
        mongo_cn.init()
    except BaseException as e:
        log.error(traceback.format_exc())
        do_except(uid_tid_lid)

    try:
        # 错误类型 1
        err_t1_name = '{}_{}_err_t1.txt'.format(import_id, 'maillist')
        err_t1_path = os.path.join(ERR_ADDR_PATH, err_t1_name)
        fp_err_t1 = open(err_t1_path, "a")
        # 错误类型 2
        err_t2_name = '{}_{}_err_t2.txt'.format(import_id, 'maillist')
        err_t2_path = os.path.join(ERR_ADDR_PATH, err_t2_name)
        fp_err_t2 = open(err_t2_path, "a")
    except:
        log.error(u'{}. init error file failure.'.format(msg))
        do_except(uid_tid_lid)
Ejemplo n.º 2
0
def init():
    global mysql_pool, mongo_cn
    conf = pyetc.load(os.path.join(ROOT, 'conf', 'setting.conf'))

    # 获取数据库
    dbconf = {'mysql': conf.mysql, 'mongo': conf.mongo}

    try:
        mysql_pool = MysqlPool.Mysql(dbconf, log)
    except BaseException as e:
        log.error(u'init mysql pool exception.')
        log.error(traceback.format_exc())
        sys.exit(1)

    try:
        mongo_cn = MongoPool.Mongo(dbconf, log)
        mongo_cn.init()
    except BaseException as e:
        log.error(traceback.format_exc())
        sys.exit(1)