summaryrefslogtreecommitdiffstats
path: root/qtip/loader
diff options
context:
space:
mode:
authorYujun Zhang <zhang.yujunz@zte.com.cn>2017-02-05 12:24:30 +0800
committerYujun Zhang <zhang.yujunz@zte.com.cn>2017-02-15 07:03:25 +0800
commitcdb8e1be12b724e9f68c7e46c9a653ec37c502cb (patch)
tree647fb60a48282deab3387deb493a1b3200aa6d96 /qtip/loader
parent0f3ad6f2db26fb91190e47c89f77fb59b7601b84 (diff)
Implement logfile collector and grep parser
JIRA: QTIP-207 JIRA: QTIP-208 Change-Id: Icc14d3097fb305e59df716636ef87504490c9d1b Signed-off-by: Yujun Zhang <zhang.yujunz@zte.com.cn>
Diffstat (limited to 'qtip/loader')
-rw-r--r--qtip/loader/file.py10
-rw-r--r--qtip/loader/module.py19
-rw-r--r--qtip/loader/plan.py12
-rw-r--r--qtip/loader/yaml_file.py6
4 files changed, 19 insertions, 28 deletions
diff --git a/qtip/loader/file.py b/qtip/loader/file.py
index 00f94818..0ea4d5b6 100644
--- a/qtip/loader/file.py
+++ b/qtip/loader/file.py
@@ -25,12 +25,12 @@ class FileLoader(BaseLoader):
_paths = [ROOT_DIR]
def __init__(self, name, paths=None):
- self._file = name
- self._abspath = self._find(name, paths=paths)
+ self._filename = name
+ self.abspath = self.find(name, paths=paths)
- def _find(self, name, paths=None):
+ def find(self, name, paths=None):
"""find a specification in searching paths"""
- paths = self._paths if paths is None else paths
+ paths = [self.abspath] if paths is None else paths
for p in paths:
abspath = path.join(p, self.RELATIVE_PATH, name)
if path.exists(abspath):
@@ -47,4 +47,4 @@ class FileLoader(BaseLoader):
item = cls(name, paths=paths)
yield {
BaseProp.NAME: name,
- BaseProp.ABSPATH: item._abspath}
+ BaseProp.ABSPATH: item.abspath}
diff --git a/qtip/loader/module.py b/qtip/loader/module.py
deleted file mode 100644
index 05cb1b76..00000000
--- a/qtip/loader/module.py
+++ /dev/null
@@ -1,19 +0,0 @@
-##############################################################################
-# Copyright (c) 2017 ZTE Corp and others.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Apache License, Version 2.0
-# which accompanies this distribution, and is available at
-# http://www.apache.org/licenses/LICENSE-2.0
-##############################################################################
-
-
-from qtip.collector.logfile import LogfileCollector
-
-
-# TODO(yujunz) more elegant way to load module dynamically
-def load_collector(type_name):
- if type_name == LogfileCollector.TYPE:
- return LogfileCollector
- else:
- raise Exception("Invalid collector type: {}".format(type_name))
diff --git a/qtip/loader/plan.py b/qtip/loader/plan.py
index 0fd9ff52..e15651a3 100644
--- a/qtip/loader/plan.py
+++ b/qtip/loader/plan.py
@@ -9,12 +9,20 @@
from qtip.base.constant import BaseProp
-from qtip.collector.base import CollectorProp as CProp
-from qtip.loader.module import load_collector
+from qtip.collector import CollectorProp as CProp
+from qtip.collector.logfile import LogfileCollector
from qtip.loader.yaml_file import YamlFileLoader
from qtip.loader.qpi import QPISpec
+# TODO(yujunz) more elegant way to load module dynamically
+def load_collector(type_name):
+ if type_name == LogfileCollector.TYPE:
+ return LogfileCollector
+ else:
+ raise Exception("Invalid collector type: {}".format(type_name))
+
+
class Plan(YamlFileLoader):
"""
a benchmark plan is consist of configuration and a QPI list
diff --git a/qtip/loader/yaml_file.py b/qtip/loader/yaml_file.py
index ccaee8db..8b78a47c 100644
--- a/qtip/loader/yaml_file.py
+++ b/qtip/loader/yaml_file.py
@@ -20,9 +20,11 @@ class YamlFileLoader(FileLoader):
def __init__(self, name, paths=None):
super(YamlFileLoader, self).__init__(name, paths)
- with open(self._abspath, 'r') as stream:
+ abspath = self.abspath
+
+ with open(abspath, 'r') as stream:
content = yaml.safe_load(stream)
if not isinstance(content, dict):
- raise InvalidContent(self._abspath)
+ raise InvalidContent(abspath)
self.content = content
self.name = content.get(BaseProp.NAME, path.splitext(name)[0])