Export machine list with master.js.

This commit is contained in:
AreWeFastYet 2012-11-29 23:28:10 +00:00
Родитель 0389747952
Коммит eb31381bb1
2 изменённых файлов: 25 добавлений и 14 удалений

Просмотреть файл

@ -17,12 +17,18 @@ class Vendor(object):
self.url = url self.url = url
self.browser = browser self.browser = browser
class Machine(object):
def __init__(self, id, os, cpu, description):
self.id = id
self.os = os
self.cpu = cpu
self.description = description
def export(self): def export(self):
return { "id": self.id, return { "id": self.id,
"name": self.name, "os": self.os,
"vendor": self.vendor_id, "cpu": self.cpu,
"url": self.url, "description": self.description
"browser": self.browser
} }
class Mode(object): class Mode(object):
@ -34,15 +40,6 @@ class Mode(object):
self.color = color self.color = color
self.level = level self.level = level
def export(self):
return { "id": self.id,
"vendor_id": self.vendor_id,
"mode": self.mode,
"name": self.name,
"color": self.color,
"level": self.level
}
class Runs(object): class Runs(object):
def __init__(self, machine_id): def __init__(self, machine_id):
self.runs = [] self.runs = []
@ -108,6 +105,13 @@ class Context(object):
b = Benchmark(row[0], row[1], row[2], row[3]) b = Benchmark(row[0], row[1], row[2], row[3])
self.benchmarks.append(b) self.benchmarks.append(b)
# Get a list of machines.
self.machines = []
c.execute("SELECT id, os, cpu, description FROM awfy_machine WHERE active = 1")
for row in c.fetchall():
m = Machine(row[0], row[1], row[2], row[3])
self.machines.append(m)
def mode(self, mode_id): def mode(self, mode_id):
return self.modeMap_[mode_id] return self.modeMap_[mode_id]
@ -130,6 +134,12 @@ class Context(object):
} }
return o return o
def exportMachines(self):
o = { }
for machine in self.machines:
o[machine.id] = machine.export()
return o
def graph(cx, runs, suite_id): def graph(cx, runs, suite_id):
c = awfy.db.cursor() c = awfy.db.cursor()

Просмотреть файл

@ -255,7 +255,8 @@ def export_aggregate_suites(cx, machine, suites):
def export_master(cx): def export_master(cx):
j = { "version": awfy.version, j = { "version": awfy.version,
"modes": cx.exportModes(), "modes": cx.exportModes(),
"vendors": cx.exportVendors() "vendors": cx.exportVendors(),
"machines": cx.exportMachines()
} }
text = "var AWFYMaster = " + json.dumps(j) + ";\n" text = "var AWFYMaster = " + json.dumps(j) + ";\n"