コード例 #1
0
                    if (date.today() - rel_followed_them_date.date()).days >= 7:
                        need_unfollow = True
                else:
                    need_unfollow = True
                if need_unfollow:
                    print 'unfollow %s because of timeout' % (uid)
                    unfollow_v2(Bestgames.ACCESS_TOKENS[0], uid)
                    db_unfollow_them(uid)
                    
            if rel_followed_me == 1:
                need_unfollow = False
                if token_version == 1:
                    if not is_followed_by_v1(token_data1, token_data2, Bestgames.UID, uid):
                        need_unfollow = True
                elif token_version == 2:
                    if not is_followed_by_v2(token_data1, Bestgames.UID, uid):
                        need_unfollow = True
                if need_unfollow:
                    print 'update %s bescause they unfollow me' % (uid)
                    db_unfollow_me(uid)
            index = index + 1
            
            time.sleep(5)
    except Exception,e:
        print e
        sys.exit()
    
    cursor.close()
    conn.close()
    
if __name__ == '__main__':
コード例 #2
0
        print e
    
    try:
        staging_cursor = staging_conn.cursor()
        staging_cursor.execute('select uid from experiments where experiment=%s and followed_us=0 and followed_them=1',(experiment))
        
        index=0
        for row in staging_cursor.fetchall():
            uid = row[0]
            access_token=Bestgames.ACCESS_TOKENS[0]
            
            print '%d: process %s' % (index, uid)
            if not is_follow_v2(access_token, Bestgames.UID, uid):
                print '%d: %s unfollow them' % (index, uid)
                unfollow_them(experiment, uid)
            if is_followed_by_v2(access_token, Bestgames.UID, uid):
                print '%d: %s followed us' % (index, uid)
                follow_me(experiment, uid)
            time.sleep(0.1)
            index = index + 1
    except Exception,e:
        print e
        
    staging_cursor.close()
    staging_conn.close()

def follow_them(experiment, uid):
    try:
        staging_conn = MySQLdb.connect(host='localhost', user='******', passwd='nameLR9969', db='bestgames', port=3306, charset='utf8')
    except Exception, e:
        print e
コード例 #3
0
                        need_unfollow = True
                else:
                    need_unfollow = True
                if need_unfollow:
                    print 'unfollow %s because of timeout' % (uid)
                    unfollow_v2(Bestgames.ACCESS_TOKENS[0], uid)
                    db_unfollow_them(uid)

            if rel_followed_me == 1:
                need_unfollow = False
                if token_version == 1:
                    if not is_followed_by_v1(token_data1, token_data2,
                                             Bestgames.UID, uid):
                        need_unfollow = True
                elif token_version == 2:
                    if not is_followed_by_v2(token_data1, Bestgames.UID, uid):
                        need_unfollow = True
                if need_unfollow:
                    print 'update %s bescause they unfollow me' % (uid)
                    db_unfollow_me(uid)
            index = index + 1

            time.sleep(5)
    except Exception, e:
        print e
        sys.exit()

    cursor.close()
    conn.close()

コード例 #4
0
     print e
 
 try:
     staging_cursor = staging_conn.cursor()
     staging_cursor.execute('select users.uid, users.token_version, users.token_data1, users.token_data2, tasks.type from tasks inner join users on tasks.uid=users.uid where tasks.name=%s and state=0 limit %s', (task, limit))
     
     index = 1
     for row in staging_cursor.fetchall():
         uid = row[0]
         version = row[1]
         taskType = row[4]
         
         print '%d: process %s' % (index, uid)
         if taskType == TaskType.FOLLOW_ME:
             if version == 1:
                 if is_followed_by_v2(Bestgames.ACCESS_TOKENS[index%8], Bestgames.UID, uid):
                     print '%s already follow me' % (uid)
                     db_follow_me(uid)
                 else:
                     follow_v1(row[2], row[3], Bestgames.UID)
                     if is_followed_by_v2(Bestgames.ACCESS_TOKENS[index%8], Bestgames.UID, uid):
                         print '%s follow me' % (uid)
                         db_follow_me(uid)
                     else:
                         print 'follow me failed'
                 time.sleep(60)
             elif version == 2:
                 if is_followed_by_v2(Bestgames.ACCESS_TOKENS[index%8], Bestgames.UID, uid):
                     print '%s already follow me' % (uid)
                     db_follow_me(uid)
                 else: