From f7364a6fc83b50e9abd669167f5193e70c8a6586 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Mon, 3 Aug 2015 15:02:14 -0300 Subject: [PATCH] latest job result: move code that updates latest job link The `update_latest_job_logs_dir` is defined in the `data_dir` module but it's only used in the `job` module. So, let's keep this code right at where it's used. Signed-off-by: Cleber Rosa --- avocado/core/data_dir.py | 18 ------------------ avocado/core/job.py | 14 +++++++++++++- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/avocado/core/data_dir.py b/avocado/core/data_dir.py index 7c018eaf..23b0847d 100755 --- a/avocado/core/data_dir.py +++ b/avocado/core/data_dir.py @@ -223,24 +223,6 @@ def create_job_logs_dir(logdir=None, unique_id=None): return debugdir -def update_latest_job_logs_dir(job_result_dir): - """ - Update the latest job result symbolic link [avocado-logs-dir]/latest. - - :param job_result_dir: full path for the current job result. - """ - basedir = os.path.dirname(job_result_dir) - basename = os.path.basename(job_result_dir) - latest = os.path.join(basedir, "latest") - if os.path.exists(latest) and not os.path.islink(latest): - raise OSError('"%s" already exists and is not a symlink' % latest) - try: - os.unlink(latest) - except OSError: - pass - os.symlink(basename, latest) - - class _TmpDirTracker(Borg): def __init__(self): diff --git a/avocado/core/job.py b/avocado/core/job.py index 99eb8ec0..ff49f2b6 100644 --- a/avocado/core/job.py +++ b/avocado/core/job.py @@ -141,7 +141,19 @@ class Job(object): id_file_obj.write("%s\n" % self.unique_id) def _update_latest_link(self): - data_dir.update_latest_job_logs_dir(self.logdir) + """ + Update the latest job result symbolic link [avocado-logs-dir]/latest. + """ + basedir = os.path.dirname(self.logdir) + basename = os.path.basename(self.logdir) + latest = os.path.join(basedir, "latest") + if os.path.exists(latest) and not os.path.islink(latest): + raise OSError('"%s" already exists and is not a symlink' % latest) + try: + os.unlink(latest) + except OSError: + pass + os.symlink(basename, latest) def _start_sysinfo(self): if hasattr(self.args, 'sysinfo'): -- GitLab