added json output format :: usage url?json=1
This commit is contained in:
BIN
unittest-logs/dbschema.pyc
Normal file
BIN
unittest-logs/dbschema.pyc
Normal file
Binary file not shown.
75
unittest-logs/unittestweb/settings.py~
Executable file
75
unittest-logs/unittestweb/settings.py~
Executable file
@@ -0,0 +1,75 @@
|
||||
# Django settings for unittestweb project.
|
||||
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
ADMINS = (
|
||||
('Murali Nandigama', 'murali.nandigama@gmail.com'),
|
||||
)
|
||||
|
||||
MANAGERS = ADMINS
|
||||
|
||||
DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
|
||||
DATABASE_NAME = 'topfailsdb' # Or path to database file if using sqlite3.
|
||||
DATABASE_USER = 'root' # Not used with sqlite3.
|
||||
DATABASE_PASSWORD = 'mkngama' # Not used with sqlite3.
|
||||
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
|
||||
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
|
||||
|
||||
# Local time zone for this installation. Choices can be found here:
|
||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||
# although not all choices may be available on all operating systems.
|
||||
# If running in a Windows environment this must be set to the same as your
|
||||
# system time zone.
|
||||
TIME_ZONE = 'America/Los_Angeles'
|
||||
|
||||
# Language code for this installation. All choices can be found here:
|
||||
# http://www.i18nguy.com/unicode/language-identifiers.html
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
SITE_ID = 1
|
||||
|
||||
# If you set this to False, Django will make some optimizations so as not
|
||||
# to load the internationalization machinery.
|
||||
USE_I18N = True
|
||||
|
||||
# Absolute path to the directory that holds media.
|
||||
# Example: "/home/media/media.lawrence.com/"
|
||||
MEDIA_ROOT = ''
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||
# trailing slash if there is a path component (optional in other cases).
|
||||
# Examples: "http://media.lawrence.com", "http://example.com/media/"
|
||||
MEDIA_URL = ''
|
||||
|
||||
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
|
||||
# trailing slash.
|
||||
# Examples: "http://foo.com/media/", "/media/".
|
||||
ADMIN_MEDIA_PREFIX = '/media/'
|
||||
|
||||
# Make this unique, and don't share it with anybody.
|
||||
SECRET_KEY = '0_020s+&-*5!y7yn@h9ubk#+4pnzq5$egrx)%5wq!11@)54gtu'
|
||||
|
||||
# List of callables that know how to import templates from various sources.
|
||||
TEMPLATE_LOADERS = (
|
||||
'django.template.loaders.filesystem.load_template_source',
|
||||
'django.template.loaders.app_directories.load_template_source',
|
||||
# 'django.template.loaders.eggs.load_template_source',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
)
|
||||
|
||||
ROOT_URLCONF = 'unittestweb.urls'
|
||||
|
||||
TEMPLATE_DIRS = (
|
||||
'./templates'
|
||||
)
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'django.contrib.contenttypes',
|
||||
'unittestweb.viewer'
|
||||
)
|
||||
@@ -58,6 +58,8 @@ class Builds(models.Model):
|
||||
return datetime.fromtimestamp(self.starttime)
|
||||
def changeset_link(self):
|
||||
return '<a href="%s/rev/%s">%s</a>' % ("http://hg.mozilla.org/mozilla-central", self.changeset, self.changeset)
|
||||
def json_changeset_link(self):
|
||||
return "%s/rev/%s" % ("http://hg.mozilla.org/mozilla-central", self.changeset)
|
||||
def tinderbox_link(self):
|
||||
if self.logfile:
|
||||
return "http://tinderbox.mozilla.org/showlog.cgi?log=%s/%s" % (self.tree.name, self.logfile)
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
from django.shortcuts import render_to_response, get_list_or_404
|
||||
from unittestweb.viewer.models import Builds, Trees, Tests, OS_CHOICES, get_most_failing_tests, get_fails_in_timerange
|
||||
import re
|
||||
from django.http import HttpResponse
|
||||
import json
|
||||
|
||||
def index(request):
|
||||
return render_to_response('viewer/index.html')
|
||||
|
||||
def latest(request):
|
||||
if request.GET.has_key('tree'):
|
||||
tree =request.GET['tree']
|
||||
failures = get_list_or_404(Tests.objects.all().order_by('-build__starttime')[:10])
|
||||
return render_to_response('viewer/latest.html', {'failures': failures})
|
||||
if request.GET.has_key('json'):
|
||||
jtext = [{"Test_name":f.name, "Build_status":f.build.status, "Logfile": f.build.tinderbox_link(),"Changeset":f.build.json_changeset_link() , "Failure_description":f.description} for f in failures]
|
||||
return HttpResponse(json.dumps(jtext))
|
||||
else:
|
||||
return render_to_response('viewer/latest.html', {'failures': failures})
|
||||
|
||||
def index(request):
|
||||
failures = get_list_or_404(Tests.objects.all().order_by('-build__starttime')[:10])
|
||||
@@ -35,7 +43,11 @@ def changeset(request, changeset):
|
||||
|
||||
def tests(request):
|
||||
test_names = Tests.objects.values('name').distinct()
|
||||
return render_to_response('viewer/tests.html', {'tests': [t['name'] for t in test_names]})
|
||||
if request.GET.has_key('json'):
|
||||
jtext = list(test_names)
|
||||
return HttpResponse(json.dumps(jtext))
|
||||
else:
|
||||
return render_to_response('viewer/tests.html', {'tests': [t['name'] for t in test_names]})
|
||||
|
||||
def test(request):
|
||||
failures = get_list_or_404(Tests.objects.filter(name__exact=request.GET['name']).order_by('-build__starttime'))
|
||||
@@ -43,7 +55,11 @@ def test(request):
|
||||
|
||||
def topfails(request):
|
||||
failures = get_most_failing_tests()
|
||||
return render_to_response('viewer/topfails.html', {'failures': failures})
|
||||
if request.GET.has_key('json'):
|
||||
jtext = list(failures)
|
||||
return HttpResponse(json.dumps(jtext))
|
||||
else:
|
||||
return render_to_response('viewer/topfails.html', {'failures': failures})
|
||||
|
||||
def Help(request):
|
||||
return render_to_response('viewer/Help.html')
|
||||
|
||||
Reference in New Issue
Block a user