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
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
def get_latest_diff(): for user in state_diff.find(): username = user['username'] if username == 'fred': print user