From 1708f79019f5348e2783d5b7994865a86931316b Mon Sep 17 00:00:00 2001 From: xudan Date: Sat, 26 Nov 2016 08:43:47 +0000 Subject: dovetail tool: reorganize statements in class DovetailConfig 1. move some statements in class DovetailConfig into function load_config_files() 2. call load_config_files() in run.py 3. this can only work correctly after moving clean_results_dir() into run.py, see JIRA:DOVETAIL-80 and gerrit https://gerrit.opnfv.org/gerrit/#/c/24929/ JIRA: DOVETAIL-55 Change-Id: I217c1c21dc6ba8849da7c00564f62d3c22cdc391 Signed-off-by: xudan --- dovetail/conf/dovetail_config.py | 24 ++++++++++++++---------- dovetail/run.py | 2 ++ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/dovetail/conf/dovetail_config.py b/dovetail/conf/dovetail_config.py index 8fa1a6d2..c37e8d07 100644 --- a/dovetail/conf/dovetail_config.py +++ b/dovetail/conf/dovetail_config.py @@ -21,19 +21,23 @@ class DovetailConfig: # testarea supported tuple, should adjust accordingly testarea_supported = ('vimops', 'nfvi', 'ipv6') - curr_path = os.path.dirname(os.path.abspath(__file__)) + dovetail_config = {} - with open(os.path.join(curr_path, 'dovetail_config.yml')) as f: - dovetail_config = yaml.safe_load(f) + @classmethod + def load_config_files(cls): + curr_path = os.path.dirname(os.path.abspath(__file__)) + with open(os.path.join(curr_path, 'dovetail_config.yml')) as f: + cls.dovetail_config = yaml.safe_load(f) - for extra_config_file in dovetail_config['include_config']: - with open(os.path.join(curr_path, extra_config_file)) as f: - extra_config = yaml.safe_load(f) - dovetail_config.update(extra_config) + for extra_config_file in cls.dovetail_config['include_config']: + with open(os.path.join(curr_path, extra_config_file)) as f: + extra_config = yaml.safe_load(f) + cls.dovetail_config.update(extra_config) - with open(os.path.join(curr_path, dovetail_config['cli_file_name'])) as f: - cmd_yml = yaml.safe_load(f) - dovetail_config['cli'] = cmd_yml[cmd_yml.keys()[0]] + path = os.path.join(curr_path, cls.dovetail_config['cli_file_name']) + with open(path) as f: + cmd_yml = yaml.safe_load(f) + cls.dovetail_config['cli'] = cmd_yml[cmd_yml.keys()[0]] @classmethod def cmd_name_trans(cls, cmd_name): diff --git a/dovetail/run.py b/dovetail/run.py index cc0e7940..865b3996 100755 --- a/dovetail/run.py +++ b/dovetail/run.py @@ -155,6 +155,8 @@ def main(*args, **kwargs): (kwargs['testsuite'], testarea)) +dt_config.load_config_files() + CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help']) if dt_config.dovetail_config['cli']['options'] is not None: for key, value in dt_config.dovetail_config['cli']['options'].items(): -- cgit 1.2.3-korg