提交 f7364a6f 编写于 作者: C Cleber Rosa

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: NCleber Rosa <crosa@redhat.com>
上级 ffb1ef5d
......@@ -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):
......
......@@ -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'):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册