Example #1
0
def user_frnd(name):
    global dispatcher
    file = open('/home/ubuntu/casebook/LOAD/file.txt', 'r',500)
    USER_PASS={}
    USER_FRND={}
    ctr=0
    for line in file:
        match = line.split(' ', 1) 
        if match:
                if match[0] in 'user':
                     MATCH= match[1].split(' ',1)
                     NEW=MATCH[1].split('"',4)
                     USER_PASS[MATCH[0]]={} 
                     USER_FRND[MATCH[0]]={}
                     password= NEW[3]
                     USER_PASS[MATCH[0]]['actual_name']=NEW[1]
                     USER_PASS[MATCH[0]]['password']=password
                elif match[0] in 'friend':
                    MATCH= match[1].split(' ',1)
                    USER_FRND[MATCH[0]]['f'+str(ctr)]=MATCH[1][0:-1]
                    ctr=ctr+1
                    USER_FRND[MATCH[1][0:-1]]['f'+str(ctr)]= MATCH[0]
                    ctr=ctr+1
                else:
                    print"inserting USER and FRIEND into cassandra ",time.asctime()
                    CASS.save_user(USER_PASS)
                    CASS.add_friend(USER_FRND)
                    dispatcher.store_user_count(len(USER_PASS.keys()))
                    break
Example #2
0
def user_frnd(name):
    global dispatcher
    #####print "in function"
    #file = open('conf.txt', 'r')
    file = open('file.txt', 'r',500)
    USER_PASS={}
    USER_FRND={}
    #file = open('conf.txt', 'r')
    ctr=0
    for line in file:
        ######print "line is:",line
        match = line.split(' ', 1) 
        #####print match[0],"------->",match[1]
        if match:
           
                #####print"in not photo- extracted:",match[0]
                if match[0] in 'user':
                     #####print "in user"
                     
                     MATCH= match[1].split(' ',1)
                     NEW=MATCH[1].split('"',4)
                     
                     USER_PASS[MATCH[0]]={} 
                     USER_FRND[MATCH[0]]={}
                     #####print NEW
                     
                     password= NEW[3]
                     USER_PASS[MATCH[0]]['actual_name']=NEW[1]
                     USER_PASS[MATCH[0]]['password']=password
                     #####print 'actual name is:',NEW[1]
                     #####print 'password is:',password
                     ##print 'user name is:',MATCH[0],'password is:',password
                     #cass.save_user(MATCH[0],stat)
                elif match[0] in 'friend':
                    ##print "line in frnd is",line
                    MATCH= match[1].split(' ',1)
                    ###print "frnds are",MATCH[0],MATCH[1][0:-1]
                    USER_FRND[MATCH[0]]['f'+str(ctr)]=MATCH[1][0:-1]
                    ctr=ctr+1
                    USER_FRND[MATCH[1][0:-1]]['f'+str(ctr)]= MATCH[0]
                    ctr=ctr+1
                    #cass.add_friend(MATCH[0],MATCH[1][0:-1])                   
                else:
                    print"inserting USER and FRIEND into cassandra ",time.asctime()
                    CASS.save_user(USER_PASS)
                    CASS.add_friend(USER_FRND)
                    dispatcher.store_user_count(len(USER_PASS.keys()))
                    break