Commit 8fcc042d authored by BERJON Matthieu's avatar BERJON Matthieu
Browse files

Updating the job detail view



I rewrote the `get_context_data` method by adding the possibility to
load either the logs from the Redis database or the log file according
the current status of the job.
Signed-off-by: BERJON Matthieu's avatarMatthieu Berjon <matthieu.berjon@inria.fr>
parent f6edd85e
......@@ -499,12 +499,26 @@ class JobDetail(LoginRequiredMixin, DetailView):
def get_context_data(self, **kwargs):
"""Recover the logs and files related to this job"""
logs = read_runner_logs(self.object.pk)
kwargs['logs'] = log
queryset = Job.objects.get(id=self.object.pk)
webapp = Webapp.objects.get(docker_name=self.object.webapp)
job = Job.objects.get(pk=self.object.pk)
dirname = os.path.join(settings.DATASTORE, str(job.id))
# Read the Redis database if job is new or running or
# read the `allgo.log` file if job is done
if job.state == Job.RUNNING or job.state == Job.NEW:
logs = read_runner_logs(self.object.pk)
else:
log_file = os.path.join(dirname, 'allgo.log')
if os.path.isfile(log_file):
with open(log_file, 'r') as log_data:
logs = log_data.read()
else:
logs = 'Can\'t load the log file'
log.error("Log file doesn't exists (job #%d)", job.id)
kwargs['logs'] = logs
# Get the files and some metadata such as the webapp version
webapp = Webapp.objects.get(docker_name=self.object.webapp.docker_name)
webapp_version = WebappVersion.objects.get(webapp=webapp)
dirname = os.path.join(settings.DATASTORE, str(queryset.id))
kwargs['webapp_version'] = webapp_version
if os.path.exists(dirname):
# put all files in a list
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment