Esempio n. 1
0
def execute_experiment(experiment):
    try:
        staging_conn = MySQLdb.connect(host='localhost', user='******', passwd='nameLR9969', db='bestgames', port=3306, charset='utf8')
    except Exception, e:
        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=0 limit 300',(experiment))
        
        index=0
        for row in staging_cursor.fetchall():
            uid = row[0]
            access_token = Bestgames.ACCESS_TOKENS[index%8]
            if is_follow_v2(access_token, Bestgames.UID, uid):
                print '%d: %s is followed' % (index, uid)
                follow_them(experiment, uid)
            else:
                print '%d: follow %s' % (index, uid)
                if follow_v2(access_token, uid):
                    if is_follow_v2(access_token, Bestgames.UID, uid):
                        follow_them(experiment, uid)
                    else:
                        print '%d: follow %s failed' % (index, uid)
                time.sleep(15)
            index = index + 1
    except Exception,e:
        print e
        
    staging_cursor.close()
Esempio n. 2
0
                 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:
                     follow_v2(row[2], Bestgames.UID)
                     time.sleep(5)
                     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(55)
         elif taskType == TaskType.FOLLOW_THEM:
             if is_follow_v2(Bestgames.ACCESS_TOKENS[index%8], Bestgames.UID, uid):
                 print '%s already follow them' % (uid)
                 db_follow_them(uid)
             else:
                 follow_v2(Bestgames.ACCESS_TOKENS[index%8], uid)
                 time.sleep(5)
                 if is_follow_v2(Bestgames.ACCESS_TOKENS[index%8], Bestgames.UID, uid):
                     print 'follow %s' % (uid)
                     db_follow_them(uid)
                 else:
                     print 'follow %s failed' % (uid)
                 time.sleep(30)
         
         db_task_processed(task, uid)
         index = index+1
 except Exception,e: