Exemplo n.º 1
0
def run_sim(request, project):
    if request.POST.has_key('content'):  # save the edited argument file
        content = request.POST.get(
            'content', False)  # in case user changed the argument file
        arg_file = request.POST.get('arg_file', False)
        if os.name == 'posix':
            fow = open(os.getcwd() + '/' + arg_file, 'w')
        else:
            fow = open(os.getcwd() + '\\' + arg_file, 'w')
        fow.write(content)
        fow.close()
        return HttpResponse('ok')
    else:  # run computation
        run_opt = {
            '--label': request.POST.get('label', False),
            '--reason': request.POST.get('reason', False),
            '--tag': request.POST.get('tag', False),
            'exec': request.POST.get('execut', False),
            '--main': request.POST.get('main_file', False),
            'args': request.POST.get('args', False)
        }
        options_list = []
        for key, item in run_opt.iteritems():
            if item:
                if key == 'args':
                    options_list.append(item)
                elif key == 'exec':
                    executable = str(os.path.basename(item))
                    if '.exe' in executable:
                        executable = executable.split('.')[0]
                    options_list.append('='.join(['--executable', executable]))
                else:
                    options_list.append('='.join([key, item]))
        run(options_list)
        ajaxTempOb = AjaxTemplate(project)
        ajaxTempOb.init_object_list(1)  # taking into consideration pagination
        if len(Record.objects.filter(project__id=project)) == 1:
            return HttpResponse('OK')
        else:
            return render_to_response('content.html', ajaxTempOb.getDict())
Exemplo n.º 2
0
def list_tags(request, project):
    if request.method == 'POST':  # user define a tag name (by clicking it)
        ajaxTempOb = AjaxTemplate(project, request.POST)
        ajaxTempOb.filter_search(request.POST)
        ajaxTempOb.init_object_list()
        dic = ajaxTempOb.getDict()
        return render_to_response('content.html', dic)
    else:
        return render_to_response('tag_list.html', {
            'tags_list': Tag.objects.all(),
            'project_name': project
        })
Exemplo n.º 3
0
def run_sim(request, project):
    if request.POST.has_key('content'):  # save the edited argument file
        content = request.POST.get('content', False)  # in case user changed the argument file
        arg_file = request.POST.get('arg_file', False)
        if os.name == 'posix':
            fow = open(os.getcwd() + '/' + arg_file, 'w')
        else:
            fow = open(os.getcwd() + '\\' + arg_file, 'w')
        fow.write(content)
        fow.close()
        return HttpResponse('ok')
    else:  # run computation
        run_opt = {'--label': request.POST.get('label', False),
                   '--reason': request.POST.get('reason', False),
                   '--tag': request.POST.get('tag', False),
                   'exec': request.POST.get('execut', False),
                   '--main': request.POST.get('main_file', False),
                   'args': request.POST.get('args', False)}
        options_list = []
        for key, item in run_opt.iteritems():
            if item:
                if key == 'args':
                    options_list.append(item)
                elif key == 'exec':
                    executable = str(os.path.basename(item))
                    if '.exe' in executable:
                        executable = executable.split('.')[0]
                    options_list.append('='.join(['--executable', executable]))
                else:
                    options_list.append('='.join([key, item]))
        run(options_list)
        ajaxTempOb = AjaxTemplate(project)
        ajaxTempOb.init_object_list(1)  # taking into consideration pagination
        if len(Record.objects.filter(project__id=project)) == 1:
            return HttpResponse('OK')
        else:
            return render_to_response('content.html', ajaxTempOb.getDict())
Exemplo n.º 4
0
def list_tags(request, project):
    if request.method == 'POST':  # user define a tag name (by clicking it)
        ajaxTempOb = AjaxTemplate(project, request.POST)
        ajaxTempOb.filter_search(request.POST)
        ajaxTempOb.init_object_list()
        dic = ajaxTempOb.getDict()
        return render_to_response('content.html', dic)
    else:
        return render_to_response('tag_list.html', {'tags_list': Tag.objects.all(), 'project_name': project})
Exemplo n.º 5
0
def list_records(request, project):
    if request.is_ajax():  # only when paginating
        ajaxTempOb = AjaxTemplate(project, request.POST)
        if ajaxTempOb.form.is_valid():
            ajaxTempOb.filter_search(request.POST)  # taking into consideration the search inquiry
            ajaxTempOb.init_object_list(ajaxTempOb.page)  # taking into consideration pagination
            # content.html is a part of record_list.html
            return render_to_response('content.html', ajaxTempOb.getDict())
        else:
            return HttpResponse('search form is not valid')
    else:
        defTempOb = DefaultTemplate(project)
        defTempOb.init_object_list()  # object_list is used in record_list.html
        return render_to_response('record_list.html', defTempOb.getDict())
Exemplo n.º 6
0
def settings(request, project):
    if request.POST.has_key('init_settings'):
        executable = request.POST.get('executable')
        try:
            Executable(executable)._find_executable(executable)
        except:
            return HttpResponse('error')
        configure(['--executable=%s' % executable])
        return HttpResponse('OK')
    web_settings = {'display_density': request.POST.get('display_density', False),
                    'nb_records_per_page': request.POST.get('nb_records_per_page', False),
                    'hidden_cols': request.POST.getlist('hidden_cols[]')}
    ajaxTempOb = AjaxTemplate(project, None)
    for key, item in web_settings.iteritems():
        if item:
            ajaxTempOb.settings[key] = item
        else:
            if key == 'hidden_cols':
                ajaxTempOb.settings[key] = None
    ajaxTempOb.save_settings()
    ajaxTempOb.init_object_list(1)
    return render_to_response('content.html', ajaxTempOb.getDict())
Exemplo n.º 7
0
def search(request, project):
    ajaxTempOb = AjaxTemplate(project, request.POST)
    if request.POST.has_key('fulltext_inquiry'):  # using the input #search_subnav
        ajaxTempOb.filter_search(request.POST)
        ajaxTempOb.init_object_list(ajaxTempOb.page)
        return render_to_response('content.html', ajaxTempOb.getDict())
    else:  # using the form
        if ajaxTempOb.form.is_valid():
            ajaxTempOb.filter_search(ajaxTempOb.form.cleaned_data)  # taking into consideration the search form
            ajaxTempOb.init_object_list(ajaxTempOb.page)  # taking into consideration pagination
            # content.html is a part of record_list.html
            return render_to_response('content.html', ajaxTempOb.getDict())
        else:
            return HttpResponse('search form is not valid')
Exemplo n.º 8
0
def search(request, project):
    ajaxTempOb = AjaxTemplate(project, request.POST)
    if request.POST.has_key(
            'fulltext_inquiry'):  # using the input #search_subnav
        ajaxTempOb.filter_search(request.POST)
        ajaxTempOb.init_object_list(ajaxTempOb.page)
        return render_to_response('content.html', ajaxTempOb.getDict())
    else:  # using the form
        if ajaxTempOb.form.is_valid():
            ajaxTempOb.filter_search(
                ajaxTempOb.form.cleaned_data
            )  # taking into consideration the search form
            ajaxTempOb.init_object_list(
                ajaxTempOb.page)  # taking into consideration pagination
            # content.html is a part of record_list.html
            return render_to_response('content.html', ajaxTempOb.getDict())
        else:
            return HttpResponse('search form is not valid')