pretty print result in <result> <report> command

Change-Id: Iac60f81b864c3cbc3cb692f557182c3e91fa4277
This commit is contained in:
Kun Huang 2015-10-29 18:12:50 +08:00
parent 84c9bd95ee
commit 9bcd4a62df
3 changed files with 12 additions and 4 deletions

View File

@ -4,3 +4,4 @@ python-novaclient
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
psutil>=1.1.1,<2.0.0
tooz>=1.19.0 # Apache-2.0
PrettyTable>=0.7,<0.8

View File

@ -3,6 +3,14 @@
# Author: Kun Huang <academicgareth@gmail.com>
from scalpels.db import api as db_api
from prettytable import PrettyTable
def pprint_result(result):
t = PrettyTable(["timestamp", "%s(%s)" % (result.name, result.unit)])
for data in result.data:
t.add_row([data[0], data[1][:100]])
print t
LOWEST=8
@ -29,8 +37,6 @@ def run(config):
print "command report: %s" % config
print "task: <%s>" % task.uuid
results = []
for ret_uuid in task.results:
ret = db_api.result_get(ret_uuid)
results.append(ret.data)
print "result <%s>, data: %s, unit: %s, name: %s" % (ret.uuid, ret.data, ret.unit, ret.name)
pprint_result(ret)

View File

@ -3,9 +3,10 @@
# Author: Kun Huang <academicgareth@gmail.com>
from scalpels.db import api as db_api
from scalpels.cli.actions import report
def run(config):
if config.get("list"):
rets = db_api.get_all_results()
for ret in rets:
print ret.uuid, ret.data
report.pprint_result(ret)