コード例 #1
0
def cleanup_diff_db():

    for entry in state_diff.find():

        username = entry['username']
        profile = get_dht_profile(username)

        if profile is None:
            #print "Not registered: %s" % username
            continue

        dht_profile_hash = get_hash(profile)

        check_user = users.find_one({"username": username})
        try:
            db_profile_hash = get_hash(check_user['profile'])
        except:
            db_profile_hash = None
            print "ERROR: %s not in DB" % username

        if dht_profile_hash == db_profile_hash:
            print "registered: %s" % username
            state_diff.remove({"username": username})
        else:
            print "profile hash doesn't match: %s" % username
コード例 #2
0
def cleanup_diff_db():

    for entry in state_diff.find():

        username = entry['username']
        profile = get_dht_profile(username)

        if profile is None:
            #print "Not registered: %s" % username
            continue

        dht_profile_hash = get_hash(profile)

        check_user = users.find_one({"username": username})
        try:
            db_profile_hash = get_hash(check_user['profile'])
        except:
            db_profile_hash = None
            print "ERROR: %s not in DB" % username

        if dht_profile_hash == db_profile_hash:
            print "registered: %s" % username
            state_diff.remove({"username": username})
        else:
            print "profile hash doesn't match: %s" % username
コード例 #3
0
def warmup_mirror():

    counter = 0

    for entry in state_diff.find():

        if entry['username'] in IGNORE_USERNAMES:
            continue

        print entry['username']
        key = entry['profile_hash']
        value = json.dumps(entry['profile'], sort_keys=True)

        print key
        print value

        try:
            resp = dht_client.set(key, value)
            pretty_print(resp)
            counter += 1
            print counter
            print '-' * 5
        except Exception as e:
            print e
            print "problem %s" % entry['username']
            print key
            print value
コード例 #4
0
def get_latest_diff():

    for user in state_diff.find():

        username = user['username']

        if username == 'fred':
            print user
コード例 #5
0
def get_latest_diff():

    for user in state_diff.find():

        username = user['username']

        if username == 'fred':
            print user