From d37cb91d489cb0f47f7831a363847fe8796a990d Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Thu, 7 Jun 2018 16:18:57 -0400 Subject: [PATCH] Asset Fetcher: make the cache dirs visible The asset fetchers cache directories are system wide, and not test specific. They're available at the test only for convenience. They relate much more to the the other data directories, and deserve to be visible by users alongside the other data directories. Signed-off-by: Cleber Rosa --- avocado/core/data_dir.py | 12 ++++++++++++ avocado/core/test.py | 7 +------ avocado/plugins/config.py | 1 + 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/avocado/core/data_dir.py b/avocado/core/data_dir.py index 1f2cb9a7..61f2634e 100755 --- a/avocado/core/data_dir.py +++ b/avocado/core/data_dir.py @@ -199,6 +199,18 @@ def create_job_logs_dir(base_dir=None, unique_id=None): % (logdir)) +def get_cache_dirs(): + """ + Returns the list of cache dirs, according to configuration and convention + """ + cache_dirs = settings.settings.get_value('datadir.paths', 'cache_dirs', + key_type=list, default=[]) + datadir_cache = os.path.join(get_data_dir(), 'cache') + if datadir_cache not in cache_dirs: + cache_dirs.append(datadir_cache) + return cache_dirs + + class _TmpDirTracker(Borg): def __init__(self): diff --git a/avocado/core/test.py b/avocado/core/test.py index df1a96b8..e14f6995 100644 --- a/avocado/core/test.py +++ b/avocado/core/test.py @@ -567,12 +567,7 @@ class Test(unittest.TestCase, TestData): Returns a list of cache directories as set in config file. """ if self.__cache_dirs is None: - cache_dirs = settings.get_value('datadir.paths', 'cache_dirs', - key_type=list, default=[]) - datadir_cache = os.path.join(data_dir.get_data_dir(), 'cache') - if datadir_cache not in cache_dirs: - cache_dirs.append(datadir_cache) - self.__cache_dirs = cache_dirs + self.__cache_dirs = data_dir.get_cache_dirs() return self.__cache_dirs @property diff --git a/avocado/plugins/config.py b/avocado/plugins/config.py index bfc7ac64..78f2911e 100644 --- a/avocado/plugins/config.py +++ b/avocado/plugins/config.py @@ -70,3 +70,4 @@ class Config(CLICmd): LOG_UI.debug(' tests ' + data_dir.get_test_dir()) LOG_UI.debug(' data ' + data_dir.get_data_dir()) LOG_UI.debug(' logs ' + data_dir.get_logs_dir()) + LOG_UI.debug(' cache ' + ", ".join(data_dir.get_cache_dirs())) -- GitLab