deleted all pyc and *.*~ files
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,108 +0,0 @@
|
||||
# This is an auto-generated Django model module.
|
||||
# You'll have to do the following manually to clean this up:
|
||||
# * Rearrange models' order
|
||||
# * Make sure each model has one field with primary_key=True
|
||||
# Feel free to rename the models, but don't rename db_table values or field names.
|
||||
#
|
||||
# Also note: You'll have to insert the output of 'django-admin.py sqlcustom [appname]'
|
||||
# into your database.
|
||||
import re
|
||||
from django.db import models, connection
|
||||
from datetime import datetime
|
||||
from time import ctime, sleep, time
|
||||
class OS():
|
||||
Windows = 0
|
||||
Mac = 1
|
||||
Linux = 2
|
||||
Unknown = 3
|
||||
|
||||
OS_CHOICES = (
|
||||
(OS.Windows, 'Windows'),
|
||||
(OS.Mac, 'Mac'),
|
||||
(OS.Linux, 'Linux'),
|
||||
(OS.Unknown, 'Unknown')
|
||||
)
|
||||
|
||||
class BuildStatus():
|
||||
Success = 0
|
||||
TestFailed = 1
|
||||
Burning = 2
|
||||
Exception = 3
|
||||
Unknown = 4
|
||||
|
||||
BUILDSTATUS_CHOICES = (
|
||||
(BuildStatus.Success, 'Success'),
|
||||
(BuildStatus.TestFailed, 'Test Failed'),
|
||||
(BuildStatus.Burning, 'Burning'),
|
||||
(BuildStatus.Exception, 'Exception'),
|
||||
(BuildStatus.Unknown, 'Unknown')
|
||||
)
|
||||
|
||||
class Trees(models.Model):
|
||||
id = models.IntegerField(primary_key=True)
|
||||
name = models.TextField(blank=True)
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
class Meta:
|
||||
db_table = 'trees'
|
||||
|
||||
class Builds(models.Model):
|
||||
id = models.IntegerField(primary_key=True)
|
||||
tree = models.ForeignKey(Trees, db_column="treeid")
|
||||
os = models.IntegerField(choices=OS_CHOICES)
|
||||
starttime = models.IntegerField(null=True, blank=True)
|
||||
status = models.IntegerField(choices=BUILDSTATUS_CHOICES)
|
||||
logfile = models.TextField(blank=True)
|
||||
changeset = models.TextField(blank=True)
|
||||
def startdate(self):
|
||||
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 tinderbox_link(self):
|
||||
if self.logfile:
|
||||
return "http://tinderbox.mozilla.org/showlog.cgi?log=%s/%s" % (self.tree.name, self.logfile)
|
||||
return "http://tinderbox.mozilla.org/showbuilds.cgi?tree=%s&maxdate=%d&hours=3" % (self.tree.name, self.starttime)
|
||||
class Meta:
|
||||
db_table = 'builds'
|
||||
|
||||
class Tests(models.Model):
|
||||
id = models.IntegerField(primary_key=True)
|
||||
build = models.ForeignKey(Builds, db_column="buildid")
|
||||
name = models.TextField(blank=True)
|
||||
description = models.TextField(blank=True)
|
||||
class Meta:
|
||||
db_table = 'tests'
|
||||
|
||||
def get_most_failing_tests():
|
||||
cursor = connection.cursor()
|
||||
cursor.execute("select count(*), name from (select builds.id, name from builds inner join tests on builds.id = tests.buildid group by builds.id, name) aaa group by name order by count(*) desc limit 25")
|
||||
for row in cursor:
|
||||
yield row
|
||||
|
||||
def get_fails_in_timerange(self):
|
||||
|
||||
# Get current time, in seconds.
|
||||
endtime = int(time())
|
||||
|
||||
#print endtime
|
||||
m = re.match("(\d+)([ymwdh])", self)
|
||||
#print m.group(1), m.group(2)
|
||||
if m is None:
|
||||
print >>sys.stderr, "ERROR: bad timespan = '%s'!" % options.timespan
|
||||
sys.exit(1)
|
||||
|
||||
timespan = int(m.group(1)) * {'y': 365 * 24 * 3600,
|
||||
'm': 30 * 24 * 3600,
|
||||
'w': 7 * 24 * 3600,
|
||||
'd': 24 * 3600,
|
||||
'h': 3600}[m.group(2)]
|
||||
# Set current time to beginning of requested timespan ending now.
|
||||
curtime = endtime - timespan
|
||||
#print curtime, timespan, endtime-curtime
|
||||
cursor = connection.cursor()
|
||||
statement = "select count(*), name from (select builds.id, name from builds inner join tests on builds.id = tests.buildid where builds.starttime >"+str(curtime)+" group by builds.id, name) aaa group by name order by count(*) DESC"
|
||||
cursor.execute(statement)
|
||||
for row in cursor:
|
||||
print row
|
||||
yield row
|
||||
|
||||
Binary file not shown.
@@ -1,55 +0,0 @@
|
||||
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
|
||||
|
||||
def index(request):
|
||||
failures = get_list_or_404(Tests.objects.all().order_by('-build__starttime')[:10])
|
||||
return render_to_response('viewer/index.html', {'failures': failures})
|
||||
|
||||
def trees(request):
|
||||
alltrees = Trees.objects.all().order_by('name')
|
||||
return render_to_response('viewer/trees.html', {'trees': alltrees})
|
||||
|
||||
def tree(request, tree):
|
||||
newestbuilds = get_list_or_404(Builds.objects.filter(tree__name__exact=tree).order_by('-starttime')[:5])
|
||||
return render_to_response('viewer/tree.html', {'tree': tree, 'newestbuilds': newestbuilds})
|
||||
|
||||
def changesets(request):
|
||||
build_csets = Builds.objects.values('changeset').distinct()
|
||||
return render_to_response('viewer/changesets.html', {'changesets': [b['changeset'] for b in build_csets]})
|
||||
|
||||
def changeset(request, changeset):
|
||||
builds = get_list_or_404(Builds, changeset__exact=changeset)
|
||||
return render_to_response('viewer/changeset.html', {'changeset': changeset, 'builds': builds})
|
||||
|
||||
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]})
|
||||
|
||||
def test(request):
|
||||
failures = get_list_or_404(Tests.objects.filter(name__exact=request.GET['name']).order_by('-build__starttime'))
|
||||
return render_to_response('viewer/test.html', {'test': request.GET['name'], 'failures': failures})
|
||||
|
||||
def topfails(request):
|
||||
failures = get_most_failing_tests()
|
||||
return render_to_response('viewer/topfails.html', {'failures': failures})
|
||||
|
||||
def timeline(request):
|
||||
name = request.GET['name']
|
||||
builds = get_list_or_404(Builds, tests__name__exact=name)
|
||||
buildlist = []
|
||||
desc_list = []
|
||||
for b in builds:
|
||||
descs = b.tests_set.filter(name__exact=name).order_by('ROWID')
|
||||
desc = '\n'.join(descs.values_list('description', flat=True))
|
||||
if desc not in desc_list:
|
||||
desc_list.append(desc)
|
||||
desc_i = desc_list.index(desc)
|
||||
buildlist.append({'build': b,
|
||||
'desctype': desc_i,
|
||||
'description': desc,
|
||||
'os': OS_CHOICES[b.os][1],
|
||||
'time': b.startdate().isoformat() + "Z",
|
||||
})
|
||||
return render_to_response('viewer/timeline.html', {'test': name,
|
||||
'descriptions': desc_list,
|
||||
'builds': buildlist})
|
||||
Reference in New Issue
Block a user