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 <>
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(
kwargs['logs'] = log
queryset = Job.objects.get(
webapp = Webapp.objects.get(docker_name=self.object.webapp)
job = Job.objects.get(
dirname = os.path.join(settings.DATASTORE, str(
# 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(
log_file = os.path.join(dirname, 'allgo.log')
if os.path.isfile(log_file):
with open(log_file, 'r') as log_data:
logs =
logs = 'Can\'t load the log file'
log.error("Log file doesn't exists (job #%d)",
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(
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