Code Review
/
functest.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Fix how tier_handler is imported"
[functest.git]
/
functest
/
utils
/
config.py
diff --git
a/functest/utils/config.py
b/functest/utils/config.py
index
84166c1
..
6b5021a
100644
(file)
--- a/
functest/utils/config.py
+++ b/
functest/utils/config.py
@@
-1,27
+1,28
@@
-import os
+#!/usr/bin/env python
import yaml
import yaml
+import six
+
+from functest.utils import env
+
class Config(object):
def __init__(self):
class Config(object):
def __init__(self):
- if 'CONFIG_FUNCTEST_YAML' not in os.environ:
- raise Exception('CONFIG_FUNCTEST_YAML not configed')
- self.config_functest = os.environ['CONFIG_FUNCTEST_YAML']
try:
try:
- with open(
self.config_functest
) as f:
+ with open(
env.ENV.CONFIG_FUNCTEST_YAML
) as f:
self.functest_yaml = yaml.safe_load(f)
self._parse(None, self.functest_yaml)
self.functest_yaml = yaml.safe_load(f)
self._parse(None, self.functest_yaml)
- except:
- raise Exception('Parse
{} failed'.format(self.config_functest
))
+ except
Exception as error
:
+ raise Exception('Parse
config failed: {}'.format(str(error)
))
self._set_others()
def _parse(self, attr_now, left_parametes):
self._set_others()
def _parse(self, attr_now, left_parametes):
- for param_n, param_v in
left_parametes.iteritems(
):
+ for param_n, param_v in
six.iteritems(left_parametes
):
attr_further = self._get_attr_further(attr_now, param_n)
attr_further = self._get_attr_further(attr_now, param_n)
- if
not isinstance(param_v, dict)
:
+ if
attr_further
:
self.__setattr__(attr_further, param_v)
self.__setattr__(attr_further, param_v)
-
else
:
+
if isinstance(param_v, dict)
:
self._parse(attr_further, param_v)
def _get_attr_further(self, attr_now, next):
self._parse(attr_further, param_v)
def _get_attr_further(self, attr_now, next):
@@
-29,7
+30,6
@@
class Config(object):
'{}_{}'.format(attr_now, next) if attr_now else next)
def _set_others(self):
'{}_{}'.format(attr_now, next) if attr_now else next)
def _set_others(self):
- self.env_active = os.path.join(self.dir_functest_conf, "env_active")
-
+ pass
CONF = Config()
CONF = Config()