def get_namespace():

	from commontools import get_json
	
	users = namecoind.name_filter('u/')

	list = [] 

	for user in users:
		try: 
			username = user['name'].lstrip('u/').lower()
			profile = get_json(user['value'])

			if 'status' in profile and profile['status'] == -1:
				continue

			if 'status' in profile and profile['status'] == 'reserved':
				continue 

			if profile == {}:
				continue

			if 'next' in profile:
				profile = full_profile_mem('u/' + username)

			result = {}
			result["username"] = username  
			result["profile"] = profile 
			list.append(result)

		except Exception as e:
			continue

	return jsonify(results=list)
def get_namespace():

    from commontools import get_json

    users = namecoind.name_filter('u/')

    list = []

    for user in users:
        try:
            username = user['name'].lstrip('u/').lower()
            profile = get_json(user['value'])

            if 'status' in profile and profile['status'] == -1:
                continue

            if 'status' in profile and profile['status'] == 'reserved':
                continue

            if profile == {}:
                continue

            if 'next' in profile:
                profile = full_profile_mem('u/' + username)

            result = {}
            result["username"] = username
            result["profile"] = profile
            list.append(result)

        except Exception as e:
            continue

    return jsonify(results=list)
Пример #3
0
    def name_show(self, input_key):

        try:
            reply = self.obj.name_show(input_key)
        except JSONRPCException as e:
            return e.error

        reply['value'] = get_json(reply['value'])

        return reply
Пример #4
0
    def name_show(self, input_key):

        try:
            reply = self.obj.name_show(input_key)
        except JSONRPCException as e:
            return e.error

        reply['value'] = get_json(reply['value'])

        return reply
Пример #5
0
def get_db_profile(username):

    try:
        user = users.find_one({"username": username})
        profile = get_json(user["profile"])

    except Exception as e:
        profile = None
        log.error("couldn't connect to database")

    return profile
Пример #6
0
def get_db_profile(username):

    try:
        user = users.find_one({"username": username})
        profile = get_json(user["profile"])

    except Exception as e:
        profile = None
        log.error("couldn't connect to database")

    return profile
Пример #7
0
def refresh_namespace(blocks, refresh_profiles=False):

    namespace = []

    info = namecoind.name_filter("u/", blocks)

    counter = 0

    for entry in info:

        username = entry["name"].lstrip("u/").lower()

        if not username_is_valid(username):
            continue

        if "expired" in entry and entry["expired"] == 1:
            continue

        profile = get_json(entry["value"])

        if profile == {}:
            continue

        namespace.append(username)

        if not refresh_profiles:
            continue

        if "next" in profile:

            profile = namecoind.get_full_profile("u/" + username)

        save_profile(username, profile)

        counter += 1

        if counter % 100 == 0:
            print counter

    save_namespace(blocks, namespace)
Пример #8
0
def re_register(current_server):

    expired_users = get_expired_names('u/')

    #ignore_users = ['frm','rfd','meng','bjorn']
    ignore_users = ['go']

    counter = 0

    for i in expired_users:

        if counter % 10 == 0:
            current_server = load_balance(current_server)
            counter += 1

        username = i['name'].lstrip('u/')

        if username in ignore_users:
            continue

        new_user = users.find_one({'username':username})

        if new_user is not None:
            print username + " in new DB"

            profile = get_json(new_user['profile'])
            try:
                process_user(username, profile, current_server, new_address=new_user['namecoind_address'])
            except Exception as e:
                print e
            print '-' * 5
            counter += 1
            continue

        old_user = old_users.find_one({'username': username})

        if old_user is not None:
            print username + " in old DB"
            profile = get_json(old_user['profile'])

            try:
                process_user(username, profile, current_server, new_address=old_user['namecoind_address'])
            except Exception as e:
                print e

            counter += 1
            continue

        profile = namecoind.name_show(i['name'])
        profile = profile['value']

        try:
            if 'status' in profile and profile['status'] == 'reserved':

                profile = profile.replace('username', 'blockchain ID')
                profile = profile.replace('*****@*****.**', '*****@*****.**')

                try:
                    process_user(username, profile, current_server)
                except Exception as e:
                    print e

                counter += 1
                continue
        except:
            print "error"
            print profile

        print username + " not our user"
        print '-' * 5