def get_benchmark_executions_quick_page(request):
    """ Returns the view for the executions quick page """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    control1 = {}
    control1['name'] = ' Quick View'
    control1['link'] = ViewUrlGenerator.get_benchmark_executions_quick_url()
    control1['icon'] = 'fa fa-bar-chart'
    control1['onclick'] = 'window.location="{0}"'.format(control1['link'])

    control2 = {}
    control2['name'] = ' Per Branch'
    control2['link'] = ViewUrlGenerator.get_benchmark_executions_branches_url()
    control2['icon'] = 'fa fa-code-fork'
    control2['onclick'] = 'window.location="{0}"'.format(control2['link'])

    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['controls'] = []
    data['controls'].append(control1)
    data['controls'].append(control2)

    return res.get_template_data(request,
                                 'presenter/benchmark_executions_quick.html',
                                 data)
def get_benchmark_definition_edit(request, definition_id):
    """ Returns html for the benchmark definition edit page """
    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['controls'] = get_definition_controls()

    def_entry = BenchmarkDefinitionController.get_benchmark_definition(definition_id)

    if def_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', data)

    obj = def_entry
    obj['url'] = {}
    obj['url']['save'] = ViewUrlGenerator.get_save_benchmark_definition_url(definition_id)
    obj['url']['delete'] = ViewUrlGenerator.get_confirm_delete_benchmark_def_url(definition_id)
    obj['url']['project_info'] = ViewUrlGenerator.get_editable_projects_info_url()
    obj['layout_selection'] = get_layout_selection(def_entry['layout']['id'])
    obj['project_selection'] = get_project_selection(def_entry['layout']['id'], def_entry['project']['id'])

    names_and_sel = []
    count = 0
    for name in obj['priority']['names']:
        nas = {}
        nas['name'] = name
        nas['selected'] = obj['priority']['current'] == count
        count = count +1
        names_and_sel.append(nas)
    obj['priority']['names'] = names_and_sel


    data['definition'] = obj

    return res.get_template_data(request, 'presenter/benchmark_definition_edit.html', data)
Пример #3
0
def prepare_pagination_bench_stacked(project_entry, branch_entry,
                                     bench_def_entry, worker_entry,
                                     page_indices):
    """ Creates pagination object for workers from indices """
    pagination = {}
    pagination['prev'] = ViewUrlGenerator.get_benchmark_execution_stacked_url(
        project_entry, branch_entry, bench_def_entry, worker_entry,
        page_indices['prev'])

    pagination[
        'current'] = ViewUrlGenerator.get_benchmark_execution_stacked_url(
            project_entry, branch_entry, bench_def_entry, worker_entry,
            page_indices['current'])

    pagination['next'] = ViewUrlGenerator.get_benchmark_execution_stacked_url(
        project_entry, branch_entry, bench_def_entry, worker_entry,
        page_indices['next'])

    pagination['pages'] = []
    for index in page_indices['page_indices']:
        pag = {}
        pag['index'] = index
        pag['url'] = ViewUrlGenerator.get_benchmark_execution_stacked_url(
            project_entry, branch_entry, bench_def_entry, worker_entry, index)
        pag['is_current'] = (index == page_indices['current'])
        pagination['pages'].append(pag)
    return pagination
Пример #4
0
def get_project_list_from_layout(request, layout_id):
    """ Return project ids, names and get-branch-list url """
    if request.method != 'GET':
        return res.get_only_get_allowed({})

    layout = BluesteelLayoutEntry.objects.filter(id=layout_id).first()
    if layout is None:
        return res.get_response(400, 'Layout not found', {})

    project_entries = BluesteelProjectEntry.objects.filter(layout=layout).order_by('order')

    projects = []
    for project in project_entries:
        obj = {}
        obj['id'] = project.id
        obj['name'] = project.name
        obj['url'] = {}
        obj['url']['project_branch_list'] = ViewUrlGenerator.get_project_branch_list_url(project.git_project.id)
        obj['url']['project_definition_list'] = ViewUrlGenerator.get_project_definition_list_url(project.id)
        projects.append(obj)

    data = {}
    data['projects'] = projects

    return res.get_response(200, 'Projects info found', data)
Пример #5
0
def prepare_workers_for_html(workers):
    """ Prepares workers for html template """
    worker_items = []

    for worker in workers:
        worker['url'] = {}
        worker['url']['single'] = ViewUrlGenerator.get_worker_url(worker['id'])
        worker['url'][
            'feed_report'] = ViewUrlGenerator.get_feed_report_form_worker_url(
                worker['id'], 1)
        worker['url']['edit'] = ViewUrlGenerator.get_worker_edit_url(
            worker['id'])
        worker['icon'] = 'fa-question-circle'

        if any(x in worker['operative_system'].lower()
               for x in ['win', 'windows']):
            worker['icon'] = 'fa-windows'

        if any(x in worker['operative_system'].lower()
               for x in ['darwin', 'osx']):
            worker['icon'] = 'fa-apple'

        if any(x in worker['operative_system'].lower() for x in ['linux']):
            worker['icon'] = 'fa-linux'

        worker_items.append(worker)
    return worker_items
def get_benchmark_execution_complete(request, bench_exec_id):
    """ Returns a benchmark execution """
    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

    exec_entry = BenchmarkExecutionEntry.objects.filter(
        id=bench_exec_id).first()

    if exec_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', data)

    obj = exec_entry.as_object()
    data[
        'results'] = ViewPrepareObjects.prepare_results_from_bench_exec_to_html(
            obj)
    data['url'] = {}
    data['url'][
        'invalidate'] = ViewUrlGenerator.get_benchmark_execution_invalidate_url(
            exec_entry.id)
    data['url'][
        'relevant'] = ViewUrlGenerator.get_benchmark_execution_relevant_url(
            exec_entry.id)

    return res.get_template_data(
        request, 'presenter/benchmark_execution_complete.html', data)
Пример #7
0
def get_projects(request, page_index):
    """ Display all branch names """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    page = Page(PROJECTS_ITEMS_PER_PAGE, page_index)
    projects, page_indices = BluesteelProjectController.get_paginated_projects_as_objects(
        page)

    items = []
    for project in projects:
        obj = {}
        obj['name'] = project['name']
        obj['url'] = {}
        obj['url']['branches'] = ViewUrlGenerator.get_project_branches_url(
            project['id'], BRANCH_COMMIT_DEPTH, 1)
        obj['url']['edit'] = ViewUrlGenerator.get_project_edit_url(
            project['id'])
        items.append(obj)

    pagination = ViewPrepareObjects.prepare_pagination_project(page_indices)

    data = {}
    data['projects'] = items
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['pagination'] = pagination

    return res.get_template_data(request, 'presenter/project_list.html', data)
def get_benchmark_definition(request, definition_id):
    """ Returns html for the benchmark definition page """
    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['controls'] = get_definition_controls()

    def_entry = BenchmarkDefinitionController.get_benchmark_definition(definition_id)

    if def_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', data)

    obj = def_entry
    obj['url'] = {}
    obj['url']['edit'] = ViewUrlGenerator.get_edit_benchmark_definition_url(definition_id)
    obj['url']['duplicate'] = ViewUrlGenerator.get_duplicate_benchmark_definition_url(definition_id)
    obj['url']['project_info'] = ViewUrlGenerator.get_editable_projects_info_url()
    obj['layout_selection'] = get_layout_selection(def_entry['layout']['id'])
    obj['project_selection'] = get_project_selection(def_entry['layout']['id'], def_entry['project']['id'])

    # Translate priority number to name.
    obj['priority']['name'] = obj['priority']['names'][obj['priority']['current']]

    data['definition'] = obj

    return res.get_template_data(request, 'presenter/benchmark_definition.html', data)
Пример #9
0
def get_worker_urls(domain, worker_id, worker_uuid):
    """ Returns all the urls associated with a worker """
    obj = {}
    obj['update_activity_point'] = ViewUrlGenerator.get_worker_update_activity_full_url(
        domain,
        worker_id
    )
    obj['worker_info_full'] = ViewUrlGenerator.get_worker_info_full_url(domain, worker_uuid)
    return obj
Пример #10
0
def prepare_project_for_html(project):
    """ Adds information to project objects for template interaction """
    project['url'] = {}
    project['url']['save'] = ViewUrlGenerator.get_save_project_url(
        project['id'])
    project['url']['delete'] = ViewUrlGenerator.get_delete_project_url(
        project['id'])
    project['url']['edit'] = ViewUrlGenerator.get_project_edit_url(
        project['id'])
    return project
Пример #11
0
def get_feed_reports_from_worker(request, worker_id, page_index):
    """ Returns a single item list of all the feeds produced by a worker """
    if request.method != 'GET':
        return res.get_only_get_allowed({})

    feed_entries = FeedEntry.objects.filter(worker__id=worker_id).order_by('-created_at')

    page = Page(FEED_REPORT_ITEMS_PER_PAGE, page_index)
    pager = Paginator(feed_entries, page.items_per_page)
    current_page = pager.page(page.page_index)
    feed_entries = current_page.object_list
    page_indices = pag.get_pagination_indices(page, PAGINATION_HALF_RANGE, pager.num_pages)

    items = []
    for report in feed_entries:
        obj = {}
        obj['name'] = 'REPORT {0}'.format(report.id)
        obj['url'] = ViewUrlGenerator.get_feed_report_url(report.id)
        items.append(obj)

    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['controls'] = get_feed_controls(worker_id, KEEP_YOUNG_COUNT)
    data['pagination'] = ViewPrepareObjects.prepare_pagination_feed_reports(worker_id, page_indices)
    data['items'] = items

    return res.get_template_data(request, 'presenter/single_item_list.html', data)
Пример #12
0
def get_project_branches(request, project_id, commit_depth, page_index):
    """ Display all the branches of a project """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    project_entry = BluesteelProjectEntry.objects.filter(id=project_id).first()
    if project_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    project = GitProjectEntry.objects.filter(
        id=project_entry.git_project.id).first()
    if project is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    page = Page(PROJECTS_BRANCHES_PER_PAGE, page_index)
    branches, page_indices = BluesteelProjectController.get_project_git_branch_data(
        page, project, commit_depth)
    branches = BenchmarkExecutionController.add_bench_exec_completed_to_branches(
        branches)

    pagination = ViewPrepareObjects.prepare_pagination_branches(
        project_entry.id, commit_depth, page_indices)

    data = {}
    data['branches'] = ViewPrepareObjects.prepare_branches_for_html(
        project_entry.id, branches)
    data['url'] = {}
    data['url'][
        'change_merge_target'] = ViewUrlGenerator.get_change_merge_target_url(
            project_entry.id)
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['pagination'] = pagination

    return res.get_template_data(request, 'presenter/project_branches.html',
                                 data)
Пример #13
0
def get_worker_all(request, page_index):
    """ Returns html for the workers page """
    if request.method != 'GET':
        return res.get_only_get_allowed({})

    worker_entries = WorkerEntry.objects.all().order_by('name')

    page = Page(WORKER_ITEMS_PER_PAGE, page_index)
    pager = Paginator(worker_entries, page.items_per_page)
    current_page = pager.page(page.page_index)
    worker_entries = current_page.object_list
    page_indices = pag.get_pagination_indices(page, PAGINATION_HALF_RANGE,
                                              pager.num_pages)

    workers = get_workers_with_benchmark_info(worker_entries)

    control = {}
    control['name'] = '  Download Worker'
    control['link'] = ViewUrlGenerator.get_download_worker_url()
    control['icon'] = 'fa fa-arrow-down'
    control['onclick'] = 'window.location="{0}"'.format(control['link'])

    pagination = ViewPrepareObjects.prepare_pagination_workers(page_indices)

    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['pagination'] = pagination
    data['workers'] = ViewPrepareObjects.prepare_workers_for_html(workers)
    data['controls'] = []
    data['controls'].append(control)

    return res.get_template_data(request, 'presenter/worker_all.html', data)
Пример #14
0
def get_workers_with_benchmark_info(worker_entries):
    """ Returns a list of workers with additional urls associated with those workers """
    workers = []
    for entry in worker_entries:
        wrk = entry.as_object()
        wrk['latest_benchmarks'] = []

        bench_execs = BenchmarkExecutionEntry.objects.filter(
            worker__id=entry.id,
            status__in=[
                BenchmarkExecutionEntry.FINISHED,
                BenchmarkExecutionEntry.FINISHED_WITH_ERRORS
            ],
        ).order_by('-updated_at')[:MAX_LATEST_BENCHMARKS]

        for bench in bench_execs:
            bench_info = {}
            bench_info['id'] = bench.id
            bench_info[
                'url'] = ViewUrlGenerator.get_benchmark_execution_complete_url(
                    bench.id)
            wrk['latest_benchmarks'].append(bench_info)

        workers.append(wrk)

    return workers
Пример #15
0
def get_project_single_branch(request, project_id, branch_id):
    """ Display all the branches of a project """
    if request.method != 'GET':
        return res.get_template_data(request, 'presenter/not_found.html', {})

    project_entry = BluesteelProjectEntry.objects.filter(id=project_id).first()
    if project_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    git_project = GitProjectEntry.objects.filter(
        id=project_entry.git_project.id).first()
    if git_project is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    branch_entry = GitBranchEntry.objects.filter(id=branch_id,
                                                 project=git_project).first()
    if branch_entry is None:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    branches = BluesteelProjectController.get_project_single_git_branch_data(
        git_project, branch_entry, BRANCH_COMMIT_DEPTH)
    branches = BenchmarkExecutionController.add_bench_exec_completed_to_branches(
        branches)

    data = {}
    data['branches'] = ViewPrepareObjects.prepare_branches_for_html(
        project_entry.id, branches)
    data['url'] = {}
    data['url'][
        'change_merge_target'] = ViewUrlGenerator.get_change_merge_target_url(
            project_entry.id)
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

    return res.get_template_data(request, 'presenter/project_branches.html',
                                 data)
Пример #16
0
def prepare_layout_for_html(layout):
    """ Adds information to layout objects for template interaction """
    layout['url'] = {}
    layout['url']['edit'] = ViewUrlGenerator.get_layout_edit_url(layout['id'])
    layout['url']['save'] = ViewUrlGenerator.get_save_layout_url(layout['id'])
    layout['url'][
        'confirm_delete'] = ViewUrlGenerator.get_confirm_delete_layout_url(
            layout['id'])
    layout['url'][
        'confirm_wipe'] = ViewUrlGenerator.get_confirm_wipe_layout_url(
            layout['id'])
    layout['url'][
        'add_project'] = ViewUrlGenerator.get_add_default_project_url(
            layout['id'])

    obj_active = {}
    obj_active['name'] = 'ACTIVE'
    obj_active['value'] = 1
    obj_active['selected'] = ''

    obj_inactive = {}
    obj_inactive['name'] = 'INACTIVE'
    obj_inactive['value'] = 0
    obj_inactive['selected'] = ''

    if layout['active'] is True:
        obj_active['selected'] = 'selected'
    else:
        obj_inactive['selected'] = 'selected'

    layout['active_selection'] = []
    layout['active_selection'].append(obj_active)
    layout['active_selection'].append(obj_inactive)

    layout['project_selection'] = []
    for index, project in enumerate(layout['projects']):
        obj = {}
        obj['name'] = project['name']
        obj['value'] = index
        obj['selected'] = ''
        if int(index) == int(layout['project_index_path']):
            obj['selected'] = 'selected'

        layout['project_selection'].append(obj)

    return layout
Пример #17
0
def get_feed_controls(worker_id, keep_young_count):
    """ Returns a list of control buttons for the feed report page """
    control1 = {}
    control1['name'] = '  Purge All Reports'
    control1['link'] = ViewUrlGenerator.get_feed_purge_all_reports_url(worker_id)
    control1['icon'] = 'fa fa-trash'
    control1['onclick'] = 'executeAndReload(\'{0}\', \'\');'.format(control1['link'])

    control2 = {}
    control2['name'] = '  Purge Old Reports'
    control2['link'] = ViewUrlGenerator.get_feed_purge_old_reports_url(worker_id, keep_young_count)
    control2['icon'] = 'fa fa-trash'
    control2['onclick'] = 'executeAndReload(\'{0}\', \'\');'.format(control2['link'])

    controls = []
    controls.append(control1)
    controls.append(control2)
    return controls
Пример #18
0
def add_project_feed_url(request, layout):
    """ Returns urls associated with every project on a given layout """
    domain = request.get_host()
    for project in layout['projects']:
        p_id = project['id']
        project[
            'feed_commits_url'] = ViewUrlGenerator.get_gitfeeder_commits_full_url(
                domain, p_id)
        project[
            'feed_delete_branches_url'] = ViewUrlGenerator.get_gitfeeder_delete_branches_full_url(
                domain, p_id)
        project[
            'feed_reports_url'] = ViewUrlGenerator.get_gitfeeder_reports_full_url(
                domain, p_id)
        project[
            'commits_hashes_url'] = ViewUrlGenerator.get_commits_known_hashes_full_url(
                domain, p_id)
    return layout
Пример #19
0
def prepare_pagination_bench_definitions(page_indices):
    """ Creates pagination object for workers from indices """
    pagination = {}
    pagination['prev'] = ViewUrlGenerator.get_benchmark_definitions_url(
        page_indices['prev'])
    pagination['current'] = ViewUrlGenerator.get_benchmark_definitions_url(
        page_indices['current'])
    pagination['next'] = ViewUrlGenerator.get_benchmark_definitions_url(
        page_indices['next'])

    pagination['pages'] = []
    for index in page_indices['page_indices']:
        pag = {}
        pag['index'] = index
        pag['url'] = ViewUrlGenerator.get_benchmark_definitions_url(index)
        pag['is_current'] = (index == page_indices['current'])
        pagination['pages'].append(pag)
    return pagination
Пример #20
0
def prepare_pagination_project(page_indices):
    """ Creates pagination object for project from indices """
    pagination = {}
    pagination['prev'] = ViewUrlGenerator.get_project_all_url(
        page_indices['prev'])
    pagination['current'] = ViewUrlGenerator.get_project_all_url(
        page_indices['current'])
    pagination['next'] = ViewUrlGenerator.get_project_all_url(
        page_indices['next'])

    pagination['pages'] = []
    for index in page_indices['page_indices']:
        pag = {}
        pag['index'] = index
        pag['url'] = ViewUrlGenerator.get_project_all_url(index)
        pag['is_current'] = (index == page_indices['current'])
        pagination['pages'].append(pag)
    return pagination
Пример #21
0
def prepare_pagination_branches(project_id, commit_depth, page_indices):
    """ Creates pagination object for branches from indices """
    pagination = {}
    pagination['prev'] = ViewUrlGenerator.get_project_branches_url(
        project_id, commit_depth, page_indices['prev'])
    pagination['current'] = ViewUrlGenerator.get_project_branches_url(
        project_id, commit_depth, page_indices['current'])
    pagination['next'] = ViewUrlGenerator.get_project_branches_url(
        project_id, commit_depth, page_indices['next'])

    pagination['pages'] = []
    for index in page_indices['page_indices']:
        pag = {}
        pag['index'] = index
        pag['url'] = ViewUrlGenerator.get_project_branches_url(
            project_id, commit_depth, index)
        pag['is_current'] = (index == page_indices['current'])
        pagination['pages'].append(pag)
    return pagination
Пример #22
0
def prepare_branches_for_html(project_id, branches):
    """ Prepare branch data adding urls before html """
    ret_branches = []
    for branch in branches:
        for commit in branch['commits']:
            commit['url'] = {}
            commit['url'][
                'executions'] = ViewUrlGenerator.get_commit_ordered_by_worker_url(
                    commit['id'])

        branch['url'] = {}
        branch['url'][
            'single'] = ViewUrlGenerator.get_project_branch_single_url(
                project_id, branch['id'])
        branch['url'][
            'links'] = ViewUrlGenerator.get_project_branch_single_links_url(
                project_id, branch['id'])
        ret_branches.append(branch)
    return ret_branches
def get_benchmark_definition_confirm_delete(request, definition_id):
    """ Confirm benchmark definition deletion """
    if request.method == 'GET':
        bench_def = BenchmarkDefinitionEntry.objects.filter(id=definition_id).first()
        if bench_def is None:
            return res.get_template_data(request, 'presenter/not_found.html', {})

        data = {}
        data['confirm'] = {}
        data['confirm']['title'] = 'Delete Benchmark Definition'
        data['confirm']['text'] = 'Are you sure you want to delete this Benchmark Definition ?'
        data['confirm']['url'] = {}
        data['confirm']['url']['accept'] = ViewUrlGenerator.get_delete_benchmark_definition_url(bench_def.id)
        data['confirm']['url']['cancel'] = ViewUrlGenerator.get_edit_benchmark_definition_url(bench_def.id)
        data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

        return res.get_template_data(request, 'presenter/confirm.html', data)
    else:
        return res.get_only_get_allowed({})
Пример #24
0
def confirm_wipe(request, layout_id):
    """ Confirm layout deletion """
    if request.method != 'GET':
        return res.get_only_get_allowed({})

    layout_entry = BluesteelLayoutEntry.objects.filter(id=layout_id).first()
    if layout_entry is None:
        return res.get_response(404, 'Bluesteel layout not found', {})

    data = {}
    data['confirm'] = {}
    data['confirm']['title'] = 'Wipe layout'
    data['confirm']['text'] = 'Are you sure you want to wipe this Layout\'s data ?'
    data['confirm']['url'] = {}
    data['confirm']['url']['accept'] = ViewUrlGenerator.get_wipe_layout_url(layout_entry.id)
    data['confirm']['url']['cancel'] = ViewUrlGenerator.get_layout_edit_url(layout_entry.id)
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

    return res.get_template_data(request, 'presenter/confirm.html', data)
Пример #25
0
def prepare_pagination_feed_reports(worker_id, page_indices):
    """ Creates pagination object for workers from indices """
    pagination = {}
    pagination['prev'] = ViewUrlGenerator.get_feed_report_form_worker_url(
        worker_id, page_indices['prev'])
    pagination['current'] = ViewUrlGenerator.get_feed_report_form_worker_url(
        worker_id, page_indices['current'])
    pagination['next'] = ViewUrlGenerator.get_feed_report_form_worker_url(
        worker_id, page_indices['next'])

    pagination['pages'] = []
    for index in page_indices['page_indices']:
        pag = {}
        pag['index'] = index
        pag['url'] = ViewUrlGenerator.get_feed_report_form_worker_url(
            worker_id, index)
        pag['is_current'] = (index == page_indices['current'])
        pagination['pages'].append(pag)
    return pagination
Пример #26
0
def get_entry_points_urls(domain):
    """ Returns bootstrap urls for workers """
    obj = {}
    obj['layouts_url'] = ViewUrlGenerator.get_layout_point_full_url(domain)
    obj['worker_info_url'] = ViewUrlGenerator.get_worker_info_point_full_url(domain)
    obj['worker_files_hash_url'] = ViewUrlGenerator.get_worker_files_hash_full_url(domain)
    obj['worker_download_url'] = ViewUrlGenerator.get_download_worker_full_url(domain)
    obj['create_worker_url'] = ViewUrlGenerator.get_worker_create_point_full_url(domain)
    obj['login_worker_url'] = ViewUrlGenerator.get_worker_login_point_full_url(domain)
    obj['acquire_benchmark_execution_url'] = ViewUrlGenerator.get_acquire_bench_exe_full_url(domain)
    obj['notifications_url'] = ViewUrlGenerator.get_notification_send_all_full_url(domain)
    return obj
Пример #27
0
def get_worker_edit(request, worker_id):
    """ Returns worker edit page to modify some workers properties """
    if request.method != 'GET':
        return res.get_only_get_allowed({})

    worker_entry = WorkerEntry.objects.filter(id=worker_id).first()
    if not worker_entry:
        return res.get_template_data(request, 'presenter/not_found.html', {})

    data = {}
    data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])
    data['worker'] = worker_entry.as_object()
    data['worker']['url'] = {}
    data['worker']['url']['save'] = ViewUrlGenerator.get_worker_save_url(
        worker_id)
    data['worker']['url']['delete'] = ViewUrlGenerator.get_worker_delete_url(
        worker_id)

    return res.get_template_data(request, 'presenter/worker_edit.html', data)
Пример #28
0
def get_commit_ordered_by_worker(request, commit_id):
    """ Returns html for the commit executions ordered by worker """
    if request.method == 'GET':
        commit_entry = GitCommitEntry.objects.filter(id=commit_id).first()
        if not commit_entry:
            return res.get_template_data(request, 'presenter/not_found.html',
                                         {})

        ret = BenchmarkExecutionController.get_bench_execs_ordered_by_worker(
            commit_entry)

        if ret['commit']['parent']['id'] != None:
            com_id = ret['commit']['parent']['id']
            ret['commit']['parent'][
                'url'] = ViewUrlGenerator.get_commit_ordered_by_worker_url(
                    com_id)

        if ret['commit']['son']['id'] != None:
            com_id = ret['commit']['son']['id']
            ret['commit']['son'][
                'url'] = ViewUrlGenerator.get_commit_ordered_by_worker_url(
                    com_id)

        for worker in ret['workers']:
            executions = []
            for execution in worker['executions']:
                obj = {}
                obj['id'] = execution['id']
                obj['name'] = execution['name']
                obj['url'] = ViewUrlGenerator.get_benchmark_execution_relevant_url(
                    execution['id'])
                executions.append(obj)
            worker['executions'] = executions

        data = {}
        data['commit_data'] = ret
        data['menu'] = ViewPrepareObjects.prepare_menu_for_html([])

        return res.get_template_data(request,
                                     'presenter/commit_by_workers.html', data)
    else:
        return res.get_template_data(request, 'presenter/not_found.html', {})
def get_definition_controls():
    """ Returns a list of control buttons for the benchmark definitions page """
    control = {}
    control['name'] = '  Add Definition'
    control['link'] = ViewUrlGenerator.get_create_benchmark_definitions_url()
    control['icon'] = 'fa fa-plus'
    control['onclick'] = 'create_new_benchmark_definition(this, \'{0}\');'.format(control['link'])

    controls = []
    controls.append(control)
    return controls
Пример #30
0
def prepare_benchmark_execution_for_html(execution, domain):
    """ Parepares an execution object to json, ie: serializing date times :D """
    obj = execution
    obj['url'] = {}
    obj['url']['save'] = ViewUrlGenerator.get_save_bench_exe_full_url(
        domain, obj['id'])

    for command in execution['definition']['command_set']['commands']:
        command['command'] = command['command'].replace(
            '{commit_hash}', execution['commit'])

    return obj