示例#1
0
def edit_nodenet():
    user_id, permissions, token = get_request_data()
    # nodenet_id = request.params.get('id', None)
    title = 'Edit Nodenet' if id is not None else 'New Nodenet'
    return template("nodenet_form.tpl", title=title,
        # nodenet_uid=nodenet_uid,
        nodenets=runtime.get_available_nodenets(),
        templates=runtime.get_available_nodenets(),
        worlds=runtime.get_available_worlds(),
        version=VERSION, user_id=user_id, permissions=permissions)
示例#2
0
def edit_nodenet():
    user_id, permissions, token = get_request_data()
    nodenet_uid = request.params.get('id')
    title = 'Edit Agent' if nodenet_uid is not None else 'New Agent'
    return template("nodenet_form.tpl", title=title,
        nodenet=None if not nodenet_uid else runtime.get_nodenet(nodenet_uid).metadata,
        devices=runtime.get_devices(),
        nodenets=runtime.get_available_nodenets(),
        worldtypes=runtime.get_available_world_types(),
        templates=runtime.get_available_nodenets(),
        worlds=runtime.get_available_worlds(),
        version=VERSION, user_id=user_id, permissions=permissions)
示例#3
0
def nodenet_list(current_nodenet=None):
    user_id, permissions, token = get_request_data()
    nodenets = runtime.get_available_nodenets()
    return template("nodenet_list", type="nodenet", user_id=user_id,
        current=current_nodenet,
        mine=dict((uid, nodenets[uid]) for uid in nodenets if nodenets[uid].owner == user_id),
        others=dict((uid, nodenets[uid]) for uid in nodenets if nodenets[uid].owner != user_id))
示例#4
0
def test_nodenet(request, test_world, engine):
    global nn_uid
    nodenets = micropsi.get_available_nodenets("Pytest User") or {}
    if nn_uid not in nodenets:
        success, nn_uid = micropsi.new_nodenet("Testnet", engine=engine, owner="Pytest User", uid='Testnet')
        micropsi.save_nodenet(nn_uid)
    return nn_uid
示例#5
0
def nodenet_mgt():
    user_id, permissions, token = get_request_data()
    if "manage nodenets" in permissions:
        notification = None
        if request.get_cookie('notification'):
            notification = json.loads(request.get_cookie('notification'))
            response.set_cookie('notification', '', path='/')
        return template("nodenet_mgt", version=VERSION, permissions=permissions,
            user_id=user_id,
            nodenet_list=runtime.get_available_nodenets(), notification=notification)
    return template("error", msg="Insufficient rights to access nodenet console")
def test_new_nodenet(test_nodenet, resourcepath, engine):
    success, nodenet_uid = micropsi.new_nodenet("Test_Nodenet", engine=engine, worldadapter="Default", owner="tester")
    assert success
    assert nodenet_uid != test_nodenet
    assert micropsi.get_available_nodenets("tester")[nodenet_uid].name == "Test_Nodenet"
    n_path = os.path.join(resourcepath, runtime.NODENET_DIRECTORY, nodenet_uid + ".json")
    assert os.path.exists(n_path)

    # get_available_nodenets
    nodenets = micropsi.get_available_nodenets()
    mynets = micropsi.get_available_nodenets("tester")
    assert test_nodenet in nodenets
    assert nodenet_uid in nodenets
    assert nodenet_uid in mynets
    assert test_nodenet not in mynets

    # delete_nodenet
    micropsi.delete_nodenet(nodenet_uid)
    assert nodenet_uid not in micropsi.get_available_nodenets()
    assert not os.path.exists(n_path)
示例#7
0
def test_nodenet(request):
    global nn_uid
    nodenets = micropsi.get_available_nodenets("Pytest User") or {}
    if nn_uid not in nodenets:
        success, nn_uid = micropsi.new_nodenet("Testnet", worldadapter="Default", owner="Pytest User", world_uid=world_uid, uid='Testnet')
        micropsi.add_node(nn_uid, 'Concept', [10, 10], uid='N1', name='N1')
        micropsi.add_link(nn_uid, 'N1', 'gen', 'N1', 'gen')
        micropsi.save_nodenet(nn_uid)

    def fin():
            micropsi.revert_nodenet(nn_uid)
    request.addfinalizer(fin)
    return nn_uid
示例#8
0
def test_nodenet(request):
    global nn_uid
    nodenets = micropsi.get_available_nodenets("Pytest User") or {}
    for uid, nn in nodenets.items():
        if(nn.name == 'Testnet'):
            nn_uid = list(nodenets.keys())[0]
    else:
        success, nn_uid = micropsi.new_nodenet("Testnet", "Default", owner="Pytest User", world_uid=world_uid, uid='Testnet')

    def fin():
        if DELETE_TEST_FILES_ON_EXIT:
            micropsi.delete_nodenet(nn_uid)
    request.addfinalizer(fin)
    return nn_uid
示例#9
0
def get_available_nodenets(user_id=None):
    if user_id and user_id not in usermanager.users:
        return False, 'User not found'
    return True, runtime.get_available_nodenets(owner=user_id)
示例#10
0
def create_worldadapter_selector(world_uid):
    nodenets = runtime.get_available_nodenets()
    worlds = runtime.get_available_worlds()
    return template("worldadapter_selector", world_uid=world_uid,
        nodenets=nodenets, worlds=worlds)
示例#11
0
def create_new_nodenet_form():
    user_id, permissions, token = get_request_data()
    nodenets = runtime.get_available_nodenets()
    worlds = runtime.get_available_worlds()
    return template("nodenet_form", user_id=user_id, template="None",
        nodenets=nodenets, worlds=worlds)
示例#12
0
def create_worldadapter_selector(world_uid=None):
    return template("worldadapter_selector",
        world_uid=world_uid,
        nodenets=runtime.get_available_nodenets(),
        worlds=runtime.get_available_worlds(),
        worldtypes=runtime.get_available_world_types())
示例#13
0
def get_available_nodenets(user_id):
    return runtime.get_available_nodenets(user_id)
示例#14
0
def get_available_nodenets(user_id=None):
    """ Return a dict of available nodenets, optionally filtered by owner"""
    if user_id and user_id not in usermanager.users:
        return False, 'User not found'
    return True, runtime.get_available_nodenets(owner=user_id)