コード例 #1
0
ファイル: views_batch.py プロジェクト: Rotaro/FisheryUI
def get_settings(request):
    """Returns session fishery simulation settings as JSONResponse.
    """
    
    session_obj = views_support.create_settings(request)
    settings = views_support.get_settings_session(session_obj)

    return JsonResponse({"settings" : settings})
コード例 #2
0
ファイル: views_batch.py プロジェクト: Rotaro/FisheryUI
def batch_study(request):
    """View for editing batch study settings.
    """
    
    session_obj = views_support.create_settings(request)

    #get settings
    sess_settings = views_support.get_settings_session(session_obj)
    list_sess_settings = []
    #convert to list of [settingname, index, value]
    for sett in fishery.MPyGetFisherySettingOrder():
        if not isinstance(sess_settings[sett], list):
            list_sess_settings.append([sett, 0, sess_settings[sett]])
    for sett in views_support.SETTINGS_LIST:
        for i in range(0, len(sess_settings[sett])):
            list_sess_settings.append([sett, i, sess_settings[sett][i]])

    return render(request, './fisheryui/batch_study.html', {"sess_settings": list_sess_settings})
コード例 #3
0
ファイル: views_simulation.py プロジェクト: Rotaro/FisheryUI
def create_simulation(request):
    """Creates fishery simulation using session settings. 
    Returns :class:`JsonResponse`.

    Returns
    ----------
    fishery_id : int
        Unique id for the fishery simulation.
    """
    
    session_obj = views_support.create_settings(request)
    settings = views_support.get_settings_session(session_obj)

    try:
        fishery.MPySetRNGSeed(-1)
        fishery_id = fishery.MPyCreateFishery(settings)
        print("Created fishery %d." % fishery_id)
    except Exception as e:
        print(e)
        fishery_id = -1
        print("Failed to create fishery. Check settings.")

    return JsonResponse({"fishery_id" : fishery_id})