pretty print result in <result> <report> command
Change-Id: Iac60f81b864c3cbc3cb692f557182c3e91fa4277
This commit is contained in:
parent
84c9bd95ee
commit
9bcd4a62df
@ -4,3 +4,4 @@ python-novaclient
|
|||||||
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
|
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
|
||||||
psutil>=1.1.1,<2.0.0
|
psutil>=1.1.1,<2.0.0
|
||||||
tooz>=1.19.0 # Apache-2.0
|
tooz>=1.19.0 # Apache-2.0
|
||||||
|
PrettyTable>=0.7,<0.8
|
||||||
|
@ -3,6 +3,14 @@
|
|||||||
# Author: Kun Huang <academicgareth@gmail.com>
|
# Author: Kun Huang <academicgareth@gmail.com>
|
||||||
|
|
||||||
from scalpels.db import api as db_api
|
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
|
LOWEST=8
|
||||||
|
|
||||||
@ -29,8 +37,6 @@ def run(config):
|
|||||||
|
|
||||||
print "command report: %s" % config
|
print "command report: %s" % config
|
||||||
print "task: <%s>" % task.uuid
|
print "task: <%s>" % task.uuid
|
||||||
results = []
|
|
||||||
for ret_uuid in task.results:
|
for ret_uuid in task.results:
|
||||||
ret = db_api.result_get(ret_uuid)
|
ret = db_api.result_get(ret_uuid)
|
||||||
results.append(ret.data)
|
pprint_result(ret)
|
||||||
print "result <%s>, data: %s, unit: %s, name: %s" % (ret.uuid, ret.data, ret.unit, ret.name)
|
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
# Author: Kun Huang <academicgareth@gmail.com>
|
# Author: Kun Huang <academicgareth@gmail.com>
|
||||||
|
|
||||||
from scalpels.db import api as db_api
|
from scalpels.db import api as db_api
|
||||||
|
from scalpels.cli.actions import report
|
||||||
|
|
||||||
def run(config):
|
def run(config):
|
||||||
if config.get("list"):
|
if config.get("list"):
|
||||||
rets = db_api.get_all_results()
|
rets = db_api.get_all_results()
|
||||||
for ret in rets:
|
for ret in rets:
|
||||||
print ret.uuid, ret.data
|
report.pprint_result(ret)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user