예제 #1
0
def add_results(info, results):
    "Return sweet results"
    build_dict = {
        'success': info.get('success', False),
        'started': info.get('start_time', ''),
        'finished': info.get('end_time', ''),
        'tags': info['tags'],
        'client': {
            'arch': info.get('arch', ''),
            'host': info.get('host', ''),
            'user': '******',
        },
        'results': []
    }

    for result in results:
        success = False
        #Status code of 0 means successful
        if result.get('status', False) == 0:
            success = True
        build_dict['results'].append({
            'success':
            success,
            'name':
            result.get('name', ''),
            'errout':
            result.get('errout', ''),
            'output':
            result.get('output', ''),
            'command':
            result.get('command', ''),
            'type':
            result.get('type', ''),
            'version_type':
            result.get('version_type', ''),
            'version_info':
            result.get('version_info', ''),
        })

    environ = {
        'PATH_INFO': '/',
        'QUERY_STRING': '',
        'REQUEST_METHOD': 'GET',
        'SCRIPT_NAME': '',
        'SERVER_NAME': 'testserver',
        'SERVER_PORT': 80,
        'SERVER_PROTOCOL': 'HTTP/1.1',
    }
    r = WSGIRequest(environ)
    r.data = build_dict
    r.META['CONTENT_TYPE'] = 'application/json'
    package = unicode(info.get('package'))
    try:
        pro, created = Project.objects.get_or_create(name=package,
                                                     slug=slugify(package))
    except:
        pass
    ProjectBuildListHandler().create(r, package)
    return "Processed Correctly"
예제 #2
0
def add_results(info, results):
    "Return sweet results"
    build_dict = {'success': info.get('success', False),
                    'started': info.get('start_time', ''),
                    'finished': info.get('end_time', ''),
                    'tags': info['tags'],
                    'client': {
                        'arch': info.get('arch', ''),
                        'host':info.get('host', ''),
                        'user': '******',
                            },
                    'results': []
                }

    for result in results:
        success = False
        #Status code of 0 means successful
        if result.get('status', False) == 0:
            success = True
        build_dict['results'].append(
                       {'success': success,
                        'name': result.get('name', ''),
                        'errout': result.get('errout', ''),
                        'output': result.get('output', ''),
                        'command': result.get('command', ''),
                        'type': result.get('type', ''),
                        'version_type': result.get('version_type', ''),
                        'version_info': result.get('version_info', ''),
                       }
        )

    environ = {
        'PATH_INFO': '/',
        'QUERY_STRING': '',
        'REQUEST_METHOD': 'GET',
        'SCRIPT_NAME': '',
        'SERVER_NAME': 'testserver',
        'SERVER_PORT': 80,
        'SERVER_PROTOCOL': 'HTTP/1.1',
    }
    r = WSGIRequest(environ)
    r.data = build_dict
    r.META['CONTENT_TYPE'] = 'application/json'
    package = unicode(info.get('package'))
    try:
        pro, created = Project.objects.get_or_create(name=package, slug=slugify(package))
    except:
        pass
    ProjectBuildListHandler().create(r, package)
    return "Processed Correctly"
예제 #3
0
def add_project(request, template_name='devmason_server/add_project.html'):
    """
    Add project

    Template: ``projects/new_project.html``
    Context:
        form
            Form object.
    """
    form = ProjectForm(request.POST or None)
    if form.is_valid():
        project, created = Project.objects.get_or_create(name=form.cleaned_data['name'],
                                                         slug=slugify(form.cleaned_data['name']))
        repo, created = Repository.objects.get_or_create(
         url=form.cleaned_data['source_repo'],
         project=project,
        )
        return HttpResponseRedirect(project.get_absolute_url())
    return render_to_response(template_name, {'form': form},
            context_instance=RequestContext(request))
예제 #4
0
def add_project(request, template_name='devmason_server/add_project.html'):
    """
    Add project

    Template: ``projects/new_project.html``
    Context:
        form
            Form object.
    """
    form = ProjectForm(request.POST or None)
    if form.is_valid():
        project, created = Project.objects.get_or_create(
            name=form.cleaned_data['name'],
            slug=slugify(form.cleaned_data['name']))
        repo, created = Repository.objects.get_or_create(
            url=form.cleaned_data['source_repo'],
            project=project,
        )
        return HttpResponseRedirect(project.get_absolute_url())
    return render_to_response(template_name, {'form': form},
                              context_instance=RequestContext(request))