From 542e419982db590e8a5cf1f2fe8083dd036cc9d6 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Tue, 16 Aug 2016 16:24:32 -0300 Subject: [PATCH] Settings: use new key type `path` where it makes sense Some settings refer to paths on the filesystem, and the use may want to set them as `~/something`. Let's use the type `path` on known configuration keys. Signed-off-by: Cleber Rosa --- avocado/core/data_dir.py | 2 +- avocado/core/sysinfo.py | 6 +++--- avocado/plugins/diff.py | 6 +++--- avocado/plugins/gdb.py | 3 ++- avocado/plugins/jobscripts.py | 4 ++-- avocado/plugins/replay.py | 6 +++--- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/avocado/core/data_dir.py b/avocado/core/data_dir.py index 80d20726..ec3c7307 100755 --- a/avocado/core/data_dir.py +++ b/avocado/core/data_dir.py @@ -59,7 +59,7 @@ def _get_settings_dir(dir_name): """ Returns a given "datadir" directory as set by the configuration system """ - return os.path.expanduser(settings.settings.get_value('datadir.paths', dir_name)) + return settings.settings.get_value('datadir.paths', dir_name, 'path') def _get_rw_dir(settings_location, system_location, user_location): diff --git a/avocado/core/sysinfo.py b/avocado/core/sysinfo.py index e511a555..9ef76bff 100644 --- a/avocado/core/sysinfo.py +++ b/avocado/core/sysinfo.py @@ -333,14 +333,14 @@ class SysInfo(object): commands_file = settings.get_value('sysinfo.collectibles', 'commands', - key_type='str', + key_type='path', default='') log.info('Commands configured by file: %s', commands_file) self.commands = genio.read_all_lines(commands_file) files_file = settings.get_value('sysinfo.collectibles', 'files', - key_type='str', + key_type='path', default='') log.info('Files configured by file: %s', files_file) self.files = genio.read_all_lines(files_file) @@ -355,7 +355,7 @@ class SysInfo(object): profiler_file = settings.get_value('sysinfo.collectibles', 'profilers', - key_type='str', + key_type='path', default='') self.profilers = genio.read_all_lines(profiler_file) diff --git a/avocado/plugins/diff.py b/avocado/plugins/diff.py index 2e82dda0..ab5430ed 100644 --- a/avocado/plugins/diff.py +++ b/avocado/plugins/diff.py @@ -336,9 +336,9 @@ class Diff(CLICmd): resultsdir = os.path.dirname(os.path.expanduser(job_id)) job_id = '' else: - logs_dir = settings.get_value('datadir.paths', 'logs_dir', - default=None) - logdir = os.path.expanduser(logs_dir) + logdir = settings.get_value(section='datadir.paths', + key='logs_dir', key_type='path', + default=None) try: resultsdir = jobdata.get_resultsdir(logdir, job_id) except ValueError as exception: diff --git a/avocado/plugins/gdb.py b/avocado/plugins/gdb.py index 3fbd90db..a74645ac 100644 --- a/avocado/plugins/gdb.py +++ b/avocado/plugins/gdb.py @@ -77,11 +77,12 @@ class GDB(CLI): gdb.GDB_ENABLE_CORE = True if args.gdb_coredump == 'on' else False system_gdb_path = utils_path.find_command('gdb', '/usr/bin/gdb') - gdb.GDB_PATH = settings.get_value('gdb.paths', 'gdb', + gdb.GDB_PATH = settings.get_value('gdb.paths', 'gdb', key_type='path', default=system_gdb_path) system_gdbserver_path = utils_path.find_command('gdbserver', '/usr/bin/gdbserver') gdb.GDBSERVER_PATH = settings.get_value('gdb.paths', 'gdbserver', + key_type='path', default=system_gdbserver_path) process.UNDEFINED_BEHAVIOR_EXCEPTION = exceptions.TestError diff --git a/avocado/plugins/jobscripts.py b/avocado/plugins/jobscripts.py index 87c88cc3..fc281e14 100644 --- a/avocado/plugins/jobscripts.py +++ b/avocado/plugins/jobscripts.py @@ -58,12 +58,12 @@ class JobScripts(JobPre, JobPost): def pre(self, job): path = settings.get_value(section=CONFIG_SECTION, - key="pre", key_type=str, + key="pre", key_type='path', default="/etc/avocado/scripts/job/pre.d/") self._run_scripts('pre', path, job) def post(self, job): path = settings.get_value(section=CONFIG_SECTION, - key="post", key_type=str, + key="post", key_type='path', default="/etc/avocado/scripts/job/post.d/") self._run_scripts('post', path, job) diff --git a/avocado/plugins/replay.py b/avocado/plugins/replay.py index 55028a56..7bfcfa38 100644 --- a/avocado/plugins/replay.py +++ b/avocado/plugins/replay.py @@ -140,9 +140,9 @@ class Replay(CLI): if args.replay_datadir is not None: resultsdir = args.replay_datadir else: - logs_dir = settings.get_value('datadir.paths', 'logs_dir', - default=None) - logdir = os.path.expanduser(logs_dir) + logdir = settings.get_value(section='datadir.paths', + key='logs_dir', key_type='path', + default=None) try: resultsdir = jobdata.get_resultsdir(logdir, args.replay_jobid) except ValueError as exception: -- GitLab