#!/usr/bin/python
thiskey="8ddbf33ad665010b2f62beb7"
def _key_hash( key) :
    hash = 5381
    length = len(key)
    for i in xrange(length) : 
        hash = ((hash << 5) + hash ) + ord(key[i])
    return hash
r11090 ="1"#        redis.Redis(host='10.75.22.239', port=11090)
r11091 ="2"#        redis.Redis(host='10.75.22.239', port=11091)
r11092 ="3"#        redis.Redis(host='10.75.22.239', port=11092)
r11093 ="4"#        redis.Redis(host='10.75.22.239', port=11093)
r11094 ="5"#        redis.Redis(host='10.75.22.240', port=11094)
r11095 ="6"#        redis.Redis(host='10.75.22.240', port=11095)
r11096 ="7"#        redis.Redis(host='10.75.22.240', port=11096)
r11097 ="8"#        redis.Redis(host='10.75.22.240', port=11097)
#print _key_hash(thiskey)%8
file_object = open('thefile.txt', 'w+')
def printkey(thiskey):
    #operator = {'0':r11090,'1':r11091,'2':r11092,'3':r11093,'4':r11094,'5':r11095,'6':r11096,'7':r11097},
    print thiskey
    s=_key_hash(thiskey)%8
    if(s==0):
        client=r11090
    elif(s==1):
        client=r11091 
    elif(s==2):                                                                                                                        
        client=r11092
    elif(s==3):                                                                                                                                                    
        client=r11093
    elif(s==4):                                                                                                                                                    
        client=r11094
    elif(s==5):                                                                                                                                                    
        client=r11095
    elif(s==6):                                                                                                                                                    
        client=r11096
    elif(s==7):                                                                                                                                                    
        client=r11097
    else:                                                                                                                                                      
        print thiskey+" hasherror"
        return -1;
    thisvalue=client#.get(thiskey)
    if(thisvalue==None):
        print "error"
        file_object.write("error:"+thiskey+" "+thisvalue);
    else:
        pass
        #print "thisvalue:"+thisvalue
    #print thisvalue 
    #file_object.write(thisvalue);
#    try:  
#        i=str(s)  
#        print "hello:"+operator.get(i)
#    except Exception as err:  
#        print("error:"+str(err))  
#    finally:  
#        print("Goodbye!")  
printkey(thiskey)



file_object.close()
