2012-11-28 12:11:12 +04:00
|
|
|
# vim: set ts=4 sw=4 tw=99 et:
|
2013-06-21 04:11:05 +04:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2012-11-28 12:11:12 +04:00
|
|
|
import awfy
|
2012-11-28 12:45:01 +04:00
|
|
|
import time
|
2012-11-28 12:11:12 +04:00
|
|
|
|
|
|
|
class Benchmark(object):
|
2013-05-08 00:46:45 +04:00
|
|
|
def __init__(self, suite_id, name, description, direction, sort_order):
|
2012-12-01 14:42:06 +04:00
|
|
|
self.id = suite_id
|
2012-11-28 12:11:12 +04:00
|
|
|
self.name = name
|
|
|
|
self.description = description
|
|
|
|
self.direction = direction
|
2013-05-08 00:46:45 +04:00
|
|
|
self.sort_order = sort_order
|
2012-11-28 12:11:12 +04:00
|
|
|
|
2012-12-01 05:20:48 +04:00
|
|
|
# Get a list of individual tests
|
|
|
|
self.tests = []
|
|
|
|
c = awfy.db.cursor()
|
2014-05-19 18:45:00 +04:00
|
|
|
c.execute("SELECT t.name \
|
|
|
|
FROM awfy_suite_test t \
|
|
|
|
JOIN awfy_suite_version v ON v.id = t.suite_version_id \
|
|
|
|
WHERE suite_id = %s \
|
|
|
|
AND visible = 1 \
|
|
|
|
GROUP BY t.name", (suite_id,))
|
2012-12-01 05:20:48 +04:00
|
|
|
for row in c.fetchall():
|
2014-05-19 18:45:00 +04:00
|
|
|
self.tests.append(row[0])
|
2012-12-01 05:20:48 +04:00
|
|
|
|
|
|
|
def export(self):
|
2012-12-01 14:42:06 +04:00
|
|
|
return { "id": self.id,
|
2012-12-01 05:20:48 +04:00
|
|
|
"name": self.name,
|
|
|
|
"description": self.description,
|
|
|
|
"direction": self.direction,
|
2014-05-19 18:45:00 +04:00
|
|
|
"tests": self.tests,
|
2013-05-08 00:46:45 +04:00
|
|
|
"sort_order": self.sort_order
|
2012-12-01 05:20:48 +04:00
|
|
|
}
|
|
|
|
|
2012-11-28 12:11:12 +04:00
|
|
|
class Vendor(object):
|
2012-12-04 03:24:02 +04:00
|
|
|
def __init__(self, id, name, vendor, url, browser, rangeURL):
|
2012-11-28 12:11:12 +04:00
|
|
|
self.id = id
|
|
|
|
self.name = name
|
|
|
|
self.vendor = vendor
|
|
|
|
self.url = url
|
|
|
|
self.browser = browser
|
2012-12-04 03:24:02 +04:00
|
|
|
self.rangeURL = rangeURL
|
2012-11-28 12:11:12 +04:00
|
|
|
|
2012-11-30 03:28:10 +04:00
|
|
|
class Machine(object):
|
2014-08-04 17:48:00 +04:00
|
|
|
def __init__(self, id, os, cpu, description, active, frontpage, pushed_separate):
|
2012-11-30 03:28:10 +04:00
|
|
|
self.id = id
|
|
|
|
self.os = os
|
|
|
|
self.cpu = cpu
|
|
|
|
self.description = description
|
2013-10-18 12:43:33 +04:00
|
|
|
self.active = active
|
2014-02-25 13:19:43 +04:00
|
|
|
self.frontpage = frontpage
|
2014-08-04 17:48:00 +04:00
|
|
|
self.pushed_separate = pushed_separate
|
|
|
|
|
|
|
|
self.suites = []
|
|
|
|
c = awfy.db.cursor()
|
|
|
|
c.execute("SELECT DISTINCT(suite_version_id) FROM fast_run \
|
|
|
|
JOIN `awfy_score` ON fast_run.id = run_id \
|
|
|
|
WHERE machine = %s", (id,))
|
|
|
|
ids = [str(row[0]) for row in c.fetchall()]
|
|
|
|
if len(ids) > 0:
|
|
|
|
c.execute("SELECT DISTINCT(awfy_suite.name) FROM awfy_suite \
|
|
|
|
JOIN `awfy_suite_version` ON suite_id = awfy_suite.id \
|
|
|
|
WHERE awfy_suite_version.id in ("+(",".join(ids))+")")
|
|
|
|
for row in c.fetchall():
|
|
|
|
self.suites.append(row[0])
|
2012-11-30 03:28:10 +04:00
|
|
|
|
2012-11-28 12:11:12 +04:00
|
|
|
def export(self):
|
|
|
|
return { "id": self.id,
|
2012-11-30 03:28:10 +04:00
|
|
|
"os": self.os,
|
|
|
|
"cpu": self.cpu,
|
2014-02-25 13:19:43 +04:00
|
|
|
"description": self.description,
|
2014-08-04 17:48:00 +04:00
|
|
|
"frontpage": self.frontpage,
|
|
|
|
"pushed_separate": self.pushed_separate,
|
|
|
|
"suites": self.suites
|
2012-11-28 12:11:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
class Mode(object):
|
2012-11-28 12:45:01 +04:00
|
|
|
def __init__(self, id, vendor, mode, name, color, level):
|
2012-11-28 12:11:12 +04:00
|
|
|
self.id = id
|
2012-11-28 12:45:01 +04:00
|
|
|
self.vendor_id = vendor
|
2012-11-28 12:11:12 +04:00
|
|
|
self.mode = mode
|
|
|
|
self.name = name
|
|
|
|
self.color = color
|
2012-11-28 12:45:01 +04:00
|
|
|
self.level = level
|
2012-11-28 12:11:12 +04:00
|
|
|
|
|
|
|
class Runs(object):
|
|
|
|
def __init__(self, machine_id):
|
|
|
|
self.runs = []
|
|
|
|
self.map_ = {}
|
|
|
|
c = awfy.db.cursor()
|
|
|
|
c.execute("SELECT fr.id, fr.stamp \
|
|
|
|
FROM fast_run fr \
|
|
|
|
JOIN awfy_score a ON fr.id = a.run_id \
|
|
|
|
WHERE fr.machine = %s \
|
|
|
|
AND fr.status <> 0 \
|
|
|
|
GROUP BY fr.id \
|
|
|
|
ORDER BY fr.stamp DESC \
|
|
|
|
LIMIT 30", [machine_id])
|
|
|
|
for row in c.fetchall():
|
|
|
|
t = (row[0], row[1])
|
|
|
|
self.map_[row[0]] = len(self.runs)
|
|
|
|
self.runs.append(t)
|
|
|
|
|
2012-11-28 12:45:01 +04:00
|
|
|
self.earliest = int(self.runs[-1][1]) - time.timezone
|
|
|
|
|
|
|
|
def slot(self, run_id):
|
|
|
|
return self.map_[run_id]
|
|
|
|
|
|
|
|
def length(self):
|
|
|
|
return len(self.runs)
|
2012-11-28 12:11:12 +04:00
|
|
|
|
|
|
|
def contains(self, run_id):
|
|
|
|
return run_id in self.map_
|
|
|
|
|
2012-11-28 12:45:01 +04:00
|
|
|
def export(self):
|
|
|
|
list = []
|
|
|
|
for run in self.runs:
|
|
|
|
t = run[1] - time.timezone
|
|
|
|
list.append(t)
|
|
|
|
return list
|
|
|
|
|
2012-11-28 12:11:12 +04:00
|
|
|
class Context(object):
|
|
|
|
def __init__(self):
|
|
|
|
# Get a list of vendors, and map vendor IDs -> vendor info
|
|
|
|
self.vendors = []
|
|
|
|
|
|
|
|
c = awfy.db.cursor()
|
2012-12-04 03:24:02 +04:00
|
|
|
c.execute("SELECT id, name, vendor, csetURL, browser, rangeURL FROM awfy_vendor")
|
2012-11-28 12:11:12 +04:00
|
|
|
for row in c.fetchall():
|
2012-12-04 03:24:02 +04:00
|
|
|
v = Vendor(row[0], row[1], row[2], row[3], row[4], row[5])
|
2012-11-28 12:11:12 +04:00
|
|
|
self.vendors.append(v)
|
|
|
|
|
|
|
|
# Get a list of modes, and a reverse mapping from DB ids.
|
|
|
|
self.modes = []
|
2012-12-01 14:42:06 +04:00
|
|
|
self.modemap = { }
|
2012-11-28 12:45:01 +04:00
|
|
|
c.execute("SELECT id, vendor_id, mode, name, color, level FROM awfy_mode WHERE level <= 10")
|
2012-11-28 12:11:12 +04:00
|
|
|
for row in c.fetchall():
|
2012-11-28 12:45:01 +04:00
|
|
|
m = Mode(row[0], row[1], row[2], row[3], row[4], row[5])
|
2012-12-01 14:42:06 +04:00
|
|
|
self.modemap[int(row[0])] = m
|
2012-11-28 12:11:12 +04:00
|
|
|
self.modes.append(m)
|
|
|
|
|
2012-12-01 05:20:48 +04:00
|
|
|
# Get a list of benchmark suites.
|
2013-10-18 11:05:42 +04:00
|
|
|
self.suitemap = {}
|
2012-11-28 12:11:12 +04:00
|
|
|
self.benchmarks = []
|
2013-05-08 00:46:45 +04:00
|
|
|
c.execute("SELECT id, name, description, better_direction, sort_order FROM awfy_suite WHERE sort_order > 0")
|
2012-11-28 12:11:12 +04:00
|
|
|
for row in c.fetchall():
|
2013-05-08 00:46:45 +04:00
|
|
|
b = Benchmark(row[0], row[1], row[2], row[3], row[4])
|
2013-10-18 11:05:42 +04:00
|
|
|
self.suitemap[row[0]] = b
|
2012-11-28 12:11:12 +04:00
|
|
|
self.benchmarks.append(b)
|
|
|
|
|
2014-05-19 18:45:00 +04:00
|
|
|
# Get a list of suite versions
|
|
|
|
self.suiteversions = []
|
|
|
|
c.execute("SELECT id, name FROM awfy_suite_version")
|
|
|
|
for row in c.fetchall():
|
|
|
|
self.suiteversions.append([row[0], row[1]])
|
|
|
|
|
2012-11-30 03:28:10 +04:00
|
|
|
# Get a list of machines.
|
|
|
|
self.machines = []
|
2014-08-04 17:48:00 +04:00
|
|
|
c.execute("SELECT id, os, cpu, description, active, frontpage, pushed_separate FROM awfy_machine WHERE active >= 1")
|
2012-11-30 03:28:10 +04:00
|
|
|
for row in c.fetchall():
|
2014-08-04 17:48:00 +04:00
|
|
|
m = Machine(row[0], row[1], row[2], row[3], row[4], row[5], row[6])
|
2012-11-30 03:28:10 +04:00
|
|
|
self.machines.append(m)
|
|
|
|
|
2012-11-28 12:45:01 +04:00
|
|
|
def exportModes(self):
|
|
|
|
o = { }
|
|
|
|
for mode in self.modes:
|
|
|
|
o[mode.id] = { "vendor_id": mode.vendor_id,
|
|
|
|
"mode": mode.mode,
|
|
|
|
"name": mode.name,
|
|
|
|
"color": mode.color
|
|
|
|
}
|
|
|
|
return o
|
|
|
|
|
|
|
|
def exportVendors(self):
|
|
|
|
o = { }
|
|
|
|
for vendor in self.vendors:
|
|
|
|
o[vendor.id] = { "name": vendor.name,
|
|
|
|
"url": vendor.url,
|
2012-12-04 03:24:02 +04:00
|
|
|
"browser": vendor.browser,
|
|
|
|
"rangeURL": vendor.rangeURL
|
2012-11-28 12:45:01 +04:00
|
|
|
}
|
|
|
|
return o
|
|
|
|
|
2012-11-30 03:28:10 +04:00
|
|
|
def exportMachines(self):
|
|
|
|
o = { }
|
|
|
|
for machine in self.machines:
|
|
|
|
o[machine.id] = machine.export()
|
|
|
|
return o
|
|
|
|
|
2012-12-01 05:20:48 +04:00
|
|
|
def exportSuites(self):
|
|
|
|
o = { }
|
|
|
|
for b in self.benchmarks:
|
2012-12-03 11:31:43 +04:00
|
|
|
o[b.name] = b.export()
|
2012-12-01 05:20:48 +04:00
|
|
|
return o
|
2012-11-28 12:11:12 +04:00
|
|
|
|
2014-05-19 18:45:00 +04:00
|
|
|
def exportSuiteVersions(self):
|
|
|
|
o = { }
|
|
|
|
for v in self.suiteversions:
|
|
|
|
o[v[0]] = v[1]
|
|
|
|
return o
|
|
|
|
|