提交 7bf988fb 编写于 作者: L Lukáš Doktor

settings: Change the way in-tree is evaluated

Currently in-tree is evaluated based on presence of config files, but in
reallity the "settings.intree" used to get tests path. Let's use it to
check for in-tree detection, which should better correspond to how this
value is being used.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 55689363
......@@ -140,9 +140,15 @@ class Settings(object):
:param config_path: Path to a config file. Useful for unittesting.
"""
self.config = ConfigParser.ConfigParser()
self.intree = False
self.config_paths = []
self.config_paths_failed = []
_source_tree_root = os.path.dirname(os.path.dirname(os.path.dirname(
sys.modules[__name__].__file__)))
# In case "examples" file exists in root, we are running from tree
if os.path.exists(os.path.join(_source_tree_root, 'examples')):
self.intree = True
else:
self.intree = False
if config_path is None:
if 'VIRTUAL_ENV' in os.environ:
cfg_dir = os.path.join(os.environ['VIRTUAL_ENV'], 'etc')
......@@ -154,7 +160,6 @@ class Settings(object):
_config_dir_system = os.path.join(cfg_dir, 'avocado')
_config_dir_system_extra = os.path.join(cfg_dir, 'avocado', 'conf.d')
_config_dir_local = os.path.join(user_dir, '.config', 'avocado')
_source_tree_root = os.path.join(sys.modules[__name__].__file__, "..", "..", "..")
_config_path_intree = os.path.join(os.path.abspath(_source_tree_root),
'avocado', 'etc', 'avocado')
_config_path_intree_extra = os.path.join(_config_path_intree, 'conf.d')
......@@ -184,7 +189,6 @@ class Settings(object):
if config_intree_extra:
for extra_file in glob.glob(os.path.join(_config_path_intree_extra, '*.conf')):
self.process_config_path(extra_file)
self.intree = True
# Override with system config
if config_system:
self.process_config_path(config_path_system)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册