diff options
author | 2022-03-03 15:29:16 +0100 | |
---|---|---|
committer | 2022-03-04 12:19:22 +0100 | |
commit | 76909625027772102e0a174c17bce5490f8a8fcf (patch) | |
tree | c3637219e8e828bc1bc59307b76657c1bbc6a4e6 /xtesting/utils | |
parent | de9462d53155221a41a375c2964f65b399a268f0 (diff) |
Search config files in tree
It allows putting configurations in classical dirs.
It fallbacks to the python package for backward compatibility.
Change-Id: Ie33b9482fb197926c7d7d66ace815fa4ae01d02d
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'xtesting/utils')
-rw-r--r-- | xtesting/utils/config.py | 23 | ||||
-rw-r--r-- | xtesting/utils/constants.py | 28 |
2 files changed, 51 insertions, 0 deletions
diff --git a/xtesting/utils/config.py b/xtesting/utils/config.py new file mode 100644 index 00000000..6f94fc8f --- /dev/null +++ b/xtesting/utils/config.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python + +# Copyright (c) 2022 Orange 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 + +# pylint: disable=missing-docstring + +import os + +from xtesting.utils import constants + + +def get_xtesting_config(filename, default): + """Search Xtesting configs (i.e. testcases.yaml)""" + for path in constants.XTESTING_PATHES: + abspath = os.path.abspath(os.path.expanduser(path)) + if os.path.isfile(os.path.join(abspath, filename)): + return os.path.join(abspath, filename) + return default diff --git a/xtesting/utils/constants.py b/xtesting/utils/constants.py index 18e03f68..f5e29e0d 100644 --- a/xtesting/utils/constants.py +++ b/xtesting/utils/constants.py @@ -1,5 +1,33 @@ #!/usr/bin/env python +# Copyright (c) 2019 Orange 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 + # pylint: disable=missing-docstring +import os +import sys + +import pkg_resources + ENV_FILE = '/var/lib/xtesting/conf/env_file' + +XTESTING_PATHES = [ + "~/.xtesting", "/etc/xtesting", os.path.join(sys.prefix + "/etc/xtesting")] + +TESTCASE_DESCRIPTION = 'testcases.yaml' +TESTCASE_DESCRIPTION_DEFAULT = pkg_resources.resource_filename( + 'xtesting', f'ci/{TESTCASE_DESCRIPTION}') + +RESULTS_DIR = '/var/lib/xtesting/results' +LOG_PATH = os.path.join(RESULTS_DIR, 'xtesting.log') +DEBUG_LOG_PATH = os.path.join(RESULTS_DIR, 'xtesting.debug.log') + +INI_PATH_DEFAULT = pkg_resources.resource_filename( + 'xtesting', 'ci/logging.ini') +DEBUG_INI_PATH_DEFAULT = pkg_resources.resource_filename( + 'xtesting', 'ci/logging.debug.ini') |