diff options
author | hongbo tian <hongbo.tianhongbo@huawei.com> | 2016-12-02 17:43:00 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2016-12-02 17:43:00 +0000 |
commit | ec43484e1c8c8123a0e45c78d6fcb5a8d5560b43 (patch) | |
tree | 45cac6c0226a826ec5a9a668d57205331215a145 | |
parent | 9b32a15781d162ca0184a689af3cffb256326f1c (diff) | |
parent | 1708f79019f5348e2783d5b7994865a86931316b (diff) |
Merge "dovetail tool: reorganize statements in class DovetailConfig"
-rw-r--r-- | dovetail/conf/dovetail_config.py | 24 | ||||
-rwxr-xr-x | 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 e5d0608e..14dc59a3 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 d24919b6..0c57b4ed 100755 --- a/dovetail/run.py +++ b/dovetail/run.py @@ -174,6 +174,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(): |