Exemple #1
0
def details(request):
    client = CbClient()

    # Phases
    test_id = request.GET['id']
    test_details = client.find(test_id)

    events = test_details.get('events', {})

    phases = list()
    for event in sorted(events):
        phases.append("{0} phase {1} at {2}".format(events[event]['phase'],
                                                    events[event]['status'],
                                                    event))

    histograms = test_details.get('histograms', {})
    histograms = dict((d, LatencyDict(a)) for d, a in histograms.iteritems())

    reports = test_details.get('reports', {})

    context = RequestContext(request, {'phases': phases,
                                       'histograms': histograms,
                                       'reports': reports,
                                       'build': test_details.get('build'),
                                       'spec': test_details.get('spec'),
                                       'ini': test_details.get('ini'),
                                       'test_id': test_id,
                                       'title': 'Test Details'})

    return render_to_response('details.html', context)
def histo(request):
    client = CbClient()

    test_id = request.POST.get('id', uuid4().hex)
    description = request.POST.get('description', uuid4().hex)
    attachment = request.POST.get('attachment', '')
    attachment = json.loads(str(attachment))

    histograms = client.find(test_id).get('histograms', {})
    histograms.update({description: attachment})

    doc = {'histograms': histograms}

    client.update(test_id, doc)

    return HttpResponse(test_id)
def report(request):
    client = CbClient()

    test_id = request.POST.get('test_id', uuid4().hex)
    description = request.POST.get('description', uuid4().hex)
    url = request.POST.get('url', '')

    reports = client.find(test_id).get('reports', {})
    reports.update({description: url})

    doc = {'reports': reports}

    client.update(test_id, doc)

    if request.POST.get('submit'):
        location = '/details?id={0}'.format(test_id)
        return redirect(location)
    else:
        return HttpResponse(test_id)
def update(request):
    client = CbClient()

    test_id = request.POST.get('id', uuid4().hex)

    build = request.POST.get('build', '')
    spec = request.POST.get('spec', '')
    ini = request.POST.get('ini', '')
    timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    phase = request.POST.get('phase', '')
    status = request.POST.get('status', '')

    events = client.find(test_id).get('events', {})
    events.update({timestamp: {'phase': phase, 'status': status}})

    doc = {'build': build,
           'spec': spec,
           'ini': ini,
           'events': events,
           'type': 'update'}

    client.update(test_id, doc)

    return HttpResponse(test_id)
Exemple #5
0
def home(request):
    client = CbClient()

    # Output data dictionary
    data = list()

    for row in client.query(ddoc='karma', view='uid')['rows']:
        latest_timestamp = max(row['value']['events'].keys())

        status = row['value']['events'][latest_timestamp]['phase'] + ': ' + \
                 row['value']['events'][latest_timestamp]['status']

        data.append({'test_id': row['id'],
                     'build': row['value'].get('build', ''),
                     'spec': row['value'].get('spec', ''),
                     'ini': row['value'].get('ini', ''),
                     'status': status,
                     'timestamp': latest_timestamp
        })

    # Response context
    context = {'title': 'Dashboard', 'data': data}

    return render_to_response('home.html', context)