Exemplo n.º 1
0
def get_add_other_info(task_detail):

    weibo_mail_account = task_detail['weibo_mail_account']
    weibo_phone_account = task_detail['weibo_phone_account']

    if weibo_mail_account:
        account_name = weibo_mail_account
    else:
        account_name = weibo_phone_account

    password = task_detail['password']

    nick_name = str(task_detail['nick_name'])
    # print 'nick_name:', nick_name, type(nick_name)
    #print 'account_name:',account_name
    #print 'password::',password
    #     print 'nick_name'
    #     print nick_name
    try:
        # # xnr = SinaLauncher(account_name,password)
        # # xnr.login()
        # # uid = xnr.uid
        # # print 'xnr::',xnr
        #     user = SinaOperateAPI().getUserShow(screen_name=nick_name)
        #     uid = user['uid']
        # #nick_name = xnr.screen_name
        user = SinaOperateAPI().getUserShow(screen_name=nick_name)
    except Exception, e:
        print e
        #     #return '账户名或密码输入错误,请检查后输入!!'
        #     #return '昵称输入错误,请检查后输入!!'
        return 'nick_name error'
Exemplo n.º 2
0
def get_add_other_info(task_detail):

    
    weibo_mail_account = task_detail['weibo_mail_account']
    weibo_phone_account = task_detail['weibo_phone_account']

    if weibo_mail_account:
        account_name = weibo_mail_account
    else:
        account_name = weibo_phone_account

    password = task_detail['password']
    
    nick_name = str(task_detail['nick_name'])
    # print 'nick_name:', nick_name, type(nick_name)
    #print 'account_name:',account_name
    #print 'password::',password
    try:
    # # xnr = SinaLauncher(account_name,password)
    # # xnr.login()
    # # uid = xnr.uid
    # # print 'xnr::',xnr
    #     user = SinaOperateAPI().getUserShow(screen_name=nick_name)
    #     uid = user['uid']
    # #nick_name = xnr.screen_name
        user = SinaOperateAPI().getUserShow(screen_name=nick_name)
    except:
    #     #return '账户名或密码输入错误,请检查后输入!!'
    #     #return '昵称输入错误,请检查后输入!!'
        return 'nick_name error'
    
    #user = get_userinfo(account_name, password)
    # print 'user:::',user
    item_dict = {}
    
    if user:
        item_dict['nick_name'] = user['screen_name']
        item_dict['location'] = user['location']
        if user['gender']=='m':
            item_dict['gender'] = u'男'
        elif user['gender']=='f':
            item_dict['gender'] = u'女'
        item_dict['age'] = '0'
        item_dict['description'] = user['description']
        item_dict['career'] = ''

    new_task_detail = dict(task_detail,**item_dict)
    
    return new_task_detail
Exemplo n.º 3
0
def get_save_step_three_1(task_detail):
    task_id = task_detail['task_id']
    #try:
    #print 'task_detail:::',task_detail
    # print 'nick_name:::',task_detail['nick_name']
    nick_name = task_detail['nick_name'].encode('utf-8')
    operate = SinaOperateAPI()
    user_info = operate.getUserShow(screen_name=nick_name)
    uid = user_info['id']
    try:
        if task_detail['weibo_mail_account']:
            uname = task_detail['weibo_mail_account']
        else:
            uname = task_detail['weibo_phone_account']
        xnr = SinaLauncher(uname, task_detail['password'])
        xnr.login()
        uid = xnr.uid
    except:
        return '账户名或密码输入错误,请检查后输入!!'
    #uid = getUserShow(screen_name=nick_name)['data']['uid']
    #query_body = {'query':{'term':{'nick_name':nick_name}},'sort':{'user_no':{'order':'desc'}}}
    #query_body = {'query':{'match_all':{}},'sort':{'user_no':{'order':'desc'}}}
    # print 'query_body:::',query_body
    #es_result = es.search(index=weibo_xnr_index_name,doc_type=weibo_xnr_index_type,body=query_body)['hits']['hits']
    #task_id = es_result[0]['_source']['xnr_user_no']
    item_exist = es.get(index=weibo_xnr_index_name,
                        doc_type=weibo_xnr_index_type,
                        id=task_id)['_source']

    item_exist['uid'] = uid
    item_exist['nick_name'] = task_detail['nick_name']
    item_exist['weibo_mail_account'] = task_detail['weibo_mail_account']
    item_exist['weibo_phone_account'] = task_detail['weibo_phone_account']
    item_exist['password'] = task_detail['password']
    item_exist['create_status'] = 2  # 创建完成
    print 'item_exists...', item_exist
    # 更新 weibo_xnr表
    print es.update(index=weibo_xnr_index_name,
                    doc_type=weibo_xnr_index_type,
                    id=task_id,
                    body={'doc': item_exist})

    mark = True

    #except:
    #mark = False
    return mark
Exemplo n.º 4
0
def get_save_step_three_1(task_detail):
    print 'hhhhhh'
    print 'task_detail...', task_detail
    task_id = task_detail['task_id']
    print 'task_id...', task_id
    nick_name = task_detail['nick_name'].encode('utf-8')
    operate = SinaOperateAPI()
    user_info = operate.getUserShow(screen_name=nick_name)
    uid = user_info['id']
    try:
        if task_detail['weibo_mail_account']:
            uname = task_detail['weibo_mail_account']
        else:
            uname = task_detail['weibo_phone_account']
        xnr = SinaLauncher(uname, task_detail['password'])
        status = xnr.login()
        if not status:
            return 'account_pwd error'
        uid = xnr.uid
    except:
        return 'account_pwd error'
    #uid = getUserShow(screen_name=nick_name)['data']['uid']
    print 'task_id2...', task_id
    item_exist = es.get(index=weibo_xnr_index_name,
                        doc_type=weibo_xnr_index_type,
                        id=task_id)['_source']
    item_exist['uid'] = uid
    item_exist['nick_name'] = task_detail['nick_name']
    item_exist['weibo_mail_account'] = task_detail['weibo_mail_account']
    item_exist['weibo_phone_account'] = task_detail['weibo_phone_account']
    item_exist['password'] = task_detail['password']
    item_exist['create_status'] = 2  # 创建完成

    # 更新 weibo_xnr表
    print es.update(index=weibo_xnr_index_name,
                    doc_type=weibo_xnr_index_type,
                    id=task_id,
                    body={'doc': item_exist})

    mark = True

    #except:
    #mark = False
    return mark