Exemple #1
0
def add_tbuser(**kwargs):
    tbuser_name = request.form.get('tbuser_name')
    tbuser_pw = request.form.get('tbuser_pw')
    verifycode = request.form.get('verifycode')
    vcodestr = request.form.get('vcodestr')
    if not all((tbuser_name, tbuser_pw, verifycode, vcodestr),):
        current_app.logger.debug('at least one input is blank !')
        return json_err('8')
    result = Tbuser.query.filter(Tbuser.tbuser_name == tbuser_name).count()
    if result > 0:
        return json_err('2')
    cookiefile = 'temp_cookie_'+tbuser_name
    b = Client(cookiefile=cookiefile)
    bduss = b.get_bduss(tbuser_name, tbuser_pw, verifycode, vcodestr)
    if not bduss:
        return json_err('5')
    try:
        user_id = int(kwargs.get('user_id'))
        tb_user = Tbuser(user_id=user_id, tbuser_name=tbuser_name,
                         bduss=bduss)
        db.session.add(tb_user)
        db.session.commit()
        return json_err('0', tbuser_id=tb_user.id, tbuser_name=tbuser_name)
    except:
        return json_err('5')
Exemple #2
0
def get_vcode(**kwargs):
    tbuser_name = request.form.get('tbuser_name')
    if not tbuser_name:
        return json_err('1')
    b = Client(cookiefile='temp_cookie_'+tbuser_name)
    vcodestr = b.get_vcodestr(tbuser_name)
    if vcodestr:
        result = TodoDelcookiefile.query.filter(
            and_(TodoDelcookiefile.filename == b.cookiefile,
                 TodoDelcookiefile.deleted == 0)).count()
        if result == 0:
            db.session.add(TodoDelcookiefile(filename=b.cookiefile))
            db.session.commit()
        return json_err('0', vcodestr=vcodestr)
    else:
        return json_err('5')
Exemple #3
0
def init_one_client(bduss):
    tc = Client()
    tc.bduss = bduss
    tc.add_value2cookie('BDUSS', bduss)
    tc.get_tbs()
    return tc