aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/core
diff options
context:
space:
mode:
authorrexlee8776 <limingjiang@huawei.com>2017-11-20 03:28:31 +0000
committerRex Lee <limingjiang@huawei.com>2017-12-15 06:20:51 +0000
commit32c0d6daa4742911c999aff47a18e085f68769af (patch)
tree34fc84f2683d0fa159d08b704a383b9577be0f78 /yardstick/benchmark/core
parent9613b999df420e0f0244fd8a1b51d62a9c8de73f (diff)
pretty cli format: runner/scenario/testcase list
JIRA: YARDSTICK-855 1. using prettytable to reformat cli below: yardstick runner list yardstick scenario list yardstick testcase list 2. remove redundant function print_hbar 3. fix pep8 problems, the framework using do_list dynamicly, so disable unused-argument check for now. Change-Id: I79e1226e21fca4624bf4436414917bd07ecabca0 Signed-off-by: rexlee8776 <limingjiang@huawei.com>
Diffstat (limited to 'yardstick/benchmark/core')
-rw-r--r--yardstick/benchmark/core/__init__.py12
-rw-r--r--yardstick/benchmark/core/runner.py18
-rw-r--r--yardstick/benchmark/core/scenario.py16
3 files changed, 22 insertions, 24 deletions
diff --git a/yardstick/benchmark/core/__init__.py b/yardstick/benchmark/core/__init__.py
index 70036ea1e..3e3aa99a1 100644
--- a/yardstick/benchmark/core/__init__.py
+++ b/yardstick/benchmark/core/__init__.py
@@ -6,10 +6,15 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+"""
+Yardstick benchmark core.
+"""
+
from __future__ import print_function
class Param(object):
+ """This class converts a parameter dictionary to an object."""
def __init__(self, kwargs):
# list
@@ -31,10 +36,3 @@ class Param(object):
# list
self.type = kwargs.get('type')
-
-
-def print_hbar(barlen):
- """print to stdout a horizontal bar"""
- print("+")
- print("-" * barlen)
- print("+")
diff --git a/yardstick/benchmark/core/runner.py b/yardstick/benchmark/core/runner.py
index 64acdaa99..b5e457c41 100644
--- a/yardstick/benchmark/core/runner.py
+++ b/yardstick/benchmark/core/runner.py
@@ -10,9 +10,10 @@
""" Handler for yardstick command 'runner' """
from __future__ import absolute_import
-from __future__ import print_function
+
+import prettytable
+
from yardstick.benchmark.runners.base import Runner
-from yardstick.benchmark.core import print_hbar
class Runners(object): # pragma: no cover
@@ -21,16 +22,15 @@ class Runners(object): # pragma: no cover
Set of commands to discover and display runner types.
"""
- def list_all(self, args):
+ def list_all(self, *args):
"""List existing runner types"""
types = Runner.get_types()
- print_hbar(78)
- print("| %-16s | %-60s" % ("Type", "Description"))
- print_hbar(78)
+ runner_table = prettytable.PrettyTable(['Type', 'Description'])
+ runner_table.align = 'l'
for rtype in types:
- print("| %-16s | %-60s" % (rtype.__execution_type__,
- rtype.__doc__.split("\n")[0]))
- print_hbar(78)
+ runner_table.add_row([rtype.__execution_type__,
+ rtype.__doc__.split("\n")[0]])
+ print(runner_table)
def show(self, args):
"""Show details of a specific runner type"""
diff --git a/yardstick/benchmark/core/scenario.py b/yardstick/benchmark/core/scenario.py
index 28eb65230..3366172a5 100644
--- a/yardstick/benchmark/core/scenario.py
+++ b/yardstick/benchmark/core/scenario.py
@@ -10,8 +10,9 @@
""" Handler for yardstick command 'scenario' """
from __future__ import absolute_import
+import prettytable
+
from yardstick.benchmark.scenarios.base import Scenario
-from yardstick.benchmark.core import print_hbar
class Scenarios(object): # pragma: no cover
@@ -20,16 +21,15 @@ class Scenarios(object): # pragma: no cover
Set of commands to discover and display scenario types.
"""
- def list_all(self, args):
+ def list_all(self, *args):
"""List existing scenario types"""
types = Scenario.get_types()
- print_hbar(78)
- print("| %-16s | %-60s" % ("Type", "Description"))
- print_hbar(78)
+ scenario_table = prettytable.PrettyTable(['Type', 'Description'])
+ scenario_table.align = 'l'
for scenario_class in types:
- print("| %-16s | %-60s" % (scenario_class.get_scenario_type(),
- scenario_class.get_description()))
- print_hbar(78)
+ scenario_table.add_row([scenario_class.get_scenario_type(),
+ scenario_class.get_description()])
+ print(scenario_table)
def show(self, args):
"""Show details of a specific scenario type"""