Merge "support generate multi results in one html"
This commit is contained in:
commit
835eadd205
@ -30,8 +30,12 @@ def generate_result_html(result):
|
||||
t = lookup.get_template("line-chart.mako")
|
||||
print t.render(**result.__dict__)
|
||||
|
||||
def generate_multiple_result_html(result):
|
||||
raise NotImplementedError("%s is not impl" % "generate_multiple_result_html")
|
||||
def generate_multiple_result_html(results):
|
||||
tmpl_dir = os.path.dirname(templates.__file__)
|
||||
lookup = TemplateLookup(directories=[tmpl_dir])
|
||||
t = lookup.get_template("multi-line-chart.mako")
|
||||
d = {"results": results}
|
||||
print t.render(**d)
|
||||
|
||||
def run(config):
|
||||
uuid = config.get("uuid")
|
||||
@ -52,6 +56,11 @@ def run(config):
|
||||
|
||||
print "command report: %s" % config
|
||||
print "task: <%s>" % task.uuid
|
||||
rets = []
|
||||
for ret_uuid in task.results:
|
||||
ret = db_api.result_get(ret_uuid)
|
||||
pprint_result(ret)
|
||||
rets.append(ret)
|
||||
if config.get("html"):
|
||||
generate_multiple_result_html(rets)
|
||||
else:
|
||||
map(pprint_result, rets)
|
||||
|
@ -34,6 +34,7 @@ def main():
|
||||
# setup report actions
|
||||
report = subparsers.add_parser("report")
|
||||
report.add_argument("--last", action="store_true", dest="last", help="report the last task")
|
||||
report.add_argument("--html", action="store_true", dest="html", help="report html to stdout instead of pretty print")
|
||||
report.add_argument("uuid", type=str, default="", nargs="?", help="report the last task")
|
||||
|
||||
# setup re-setup actions
|
||||
|
43
scalpels/templates/multi-line-chart.mako
Normal file
43
scalpels/templates/multi-line-chart.mako
Normal file
@ -0,0 +1,43 @@
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript"
|
||||
src="https://www.google.com/jsapi?autoload={
|
||||
'modules':[{
|
||||
'name':'visualization',
|
||||
'version':'1',
|
||||
'packages':['corechart']
|
||||
}]
|
||||
}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
google.setOnLoadCallback(drawChart);
|
||||
|
||||
function drawChart() {
|
||||
|
||||
% for ret in results:
|
||||
var data_${ret.id} = google.visualization.arrayToDataTable([
|
||||
['Timestamp', '${ret.unit}'],
|
||||
% for item in ret.data:
|
||||
[${item[0]}, ${item[1]}],
|
||||
% endfor
|
||||
]);
|
||||
|
||||
var options_${ret.id} = {
|
||||
title: '${ret.name}',
|
||||
curveType: 'function',
|
||||
legend: { position: 'bottom' }
|
||||
};
|
||||
|
||||
var chart_${ret.id} = new google.visualization.LineChart(document.getElementById('chart_${ret.id}'));
|
||||
|
||||
chart_${ret.id}.draw(data_${ret.id}, options_${ret.id});
|
||||
% endfor
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
% for ret in results:
|
||||
<div id="chart_${ret.id}" style="width: 1600px; height: 200px"></div>
|
||||
% endfor
|
||||
</body>
|
||||
</html>
|
@ -32,5 +32,6 @@ sleep 120
|
||||
sca stop
|
||||
|
||||
for i in `sca result --list --short | tail -n2`; do
|
||||
sca result $i --html > $BASE/logs/scalpels-test-$i.html
|
||||
sca result $i --html > $BASE/logs/scalpels-result-$i.html
|
||||
done
|
||||
sca report --html > $BASE/logs/scalpels-report.html
|
||||
|
Loading…
x
Reference in New Issue
Block a user