~ev/errors/openid_auth_failure

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import apt
import datetime
import json

from django.contrib.auth import logout
from django.contrib.auth.decorators import login_required
from django.contrib.auth.decorators import user_passes_test
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.template.loader import render_to_string
from django.http import HttpResponse, HttpResponseRedirect
from errors import cassandra
from launchpad import get_release_for_binary
from metrics import measure_view
from django.template import RequestContext
from errors.decorators import member_of
from pycassa.util import OrderedDict

def jsonify (items):
    ret = [{'signature' : key, 'value' : value } for key, value in items]
    return json.dumps(ret)

@measure_view
def user(request, user_token):
    c = {'oopses' : cassandra.get_user_crashes(user_token)}
    return render(request, 'user.html', c)

def login_failure(request, message, status=403,
                  template_name='login_failure.html', exception=None):
    """Render an error page to the user."""

    context = {
        'message': message,
        'exception': exception,
    }
    rc = RequestContext(request)
    data = render_to_string(template_name, context, context_instance=rc)
    return HttpResponse(data, status=status)

@measure_view
@login_required
@member_of(['canonical-ubuntu-platform'], login_failure)
def bucket(request):
    bucketid = request.GET.get('id', '').encode('UTF-8')
    if not bucketid:
        return HttpResponse('')

    oopses = cassandra.get_crashes_for_bucket(bucketid)
    counts = cassandra.get_counts_for_bucket(bucketid, 180)
    traceback = cassandra.get_traceback_for_bucket(bucketid)
    metadata = cassandra.get_metadata_for_bucket(bucketid)
    versions = cassandra.get_versions_for_bucket(bucketid)

    if not traceback:
        (stacktrace, thread_stacktrace) = cassandra.get_stacktrace_for_bucket(bucketid)
    else:
        stacktrace = None
        thread_stacktrace = None

    package = metadata.get('Source', '')
    if package:
        title_string = 'Problem %s for %s' % (bucketid.decode('UTF-8'), package)
        releases = {}
        for version in versions:
            releases[version] = (get_release_for_binary(package, version), versions[version])
    else:
        releases = None
        title_string = 'Problem %s' % bucketid.decode('UTF-8')
        releases = dict((version, ([], versions[version])) for version in versions)

    releases = OrderedDict(sorted(releases.items(), cmp=apt.apt_pkg.version_compare, key=lambda t: t[0]))
    report = metadata.get('CreatedBug', '') or metadata.get('LaunchpadBug', '')

    c = {'title' : title_string,
         'oopses' : oopses,
         'stacktrace' : stacktrace,
         'thread_stacktrace' : thread_stacktrace,
         'traceback' : traceback,
         'counts' : counts,
         'report' : report,
         'releases': releases}
    return render(request, 'bucket.html', c)

@measure_view
@login_required
@member_of(['canonical-ubuntu-platform'], login_failure)
def oops(request, oopsid):
    # TODO delete Stacktrace and ThreadStacktrace from here, as they wont be useful
    c = {'title' : 'Problem instance %s' % oopsid,
         'oops' : cassandra.get_crash(oopsid)}
    return render(request, 'oops.html', c)

@measure_view
def main(request):
    return render(request, 'main.html')

@measure_view
def retracers_average_processing_time(request):
    c = { 'graph_type' : 'average-processing-time' }
    return render(request, 'retracers.html', c)

@measure_view
def retracers_results(request):
    c = { 'graph_type' : 'results' }
    return render(request, 'retracers.html', c)

@measure_view
def instances_count(request):
    c = { 'graph_type' : 'instances' }
    return render(request, 'retracers.html', c)

def logout_view(request):
    logout(request)
    return HttpResponseRedirect('/')