diff options
author | Taseer <taseer94@gmail.com> | 2017-06-29 05:24:25 +0500 |
---|---|---|
committer | Taseer <taseer94@gmail.com> | 2017-06-29 21:04:03 +0500 |
commit | 0a3a3045b97eee0583de82b532880b96807bd82a (patch) | |
tree | a1e910bed36d6cfd0cdec151beee5e5e57e7a126 /qtip/reporter/console.py | |
parent | 76cb6b08ce04492bd02bec43487a82f99a0a2c5f (diff) |
Integrate Report with CLI.
- Migrate fixtures to conftest to be used by multiple files
Change-Id: I9a705b93189ac1f2e6fd2fc4e3f05aec7af379f1
Signed-off-by: Taseer Ahmed <taseer94@gmail.com>
Diffstat (limited to 'qtip/reporter/console.py')
-rw-r--r-- | qtip/reporter/console.py | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/qtip/reporter/console.py b/qtip/reporter/console.py index da04930f..9aaa5f78 100644 --- a/qtip/reporter/console.py +++ b/qtip/reporter/console.py @@ -7,14 +7,12 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -import glob import json +import os from os import path -from jinja2 import Environment -from jinja2 import FileSystemLoader from qtip.base import BaseActor -from qtip.reporter import filters + ROOT_DIR = path.join(path.dirname(__file__), path.pardir, path.pardir) @@ -22,25 +20,9 @@ ROOT_DIR = path.join(path.dirname(__file__), path.pardir, path.pardir) class ConsoleReporter(BaseActor): """ report benchmark result to console """ - def __init__(self, config, parent=None): - super(ConsoleReporter, self).__init__(config, parent=parent) - - # TODO (taseer) load template from config - tpl_path = path.join(path.dirname(__file__), 'templates') - tpl_loader = FileSystemLoader(tpl_path) - self._env = Environment(loader=tpl_loader) - self._env.filters['justify'] = filters.justify - - def load_result(self, result_path): - result_dirs = glob.glob('{}/qtip-*'.format(result_path)) - # select the last (latest) directory for rendering report, result_dirs[-1] - with open(path.join(result_path, result_dirs[-1], 'result.json')) as sample: - result = json.load(sample) + @staticmethod + def load_result(): + result_path = path.join(os.getcwd(), 'results', 'current', 'qpi.json') + with open(result_path) as qpi: + result = json.load(qpi) return result - - def render(self, metric, result_path): - template = self._env.get_template('base.j2') - var_dict = self.load_result(result_path) - var_dict['metric_name'] = metric - out = template.render(var_dict) - return out |