From e00f64a22661dd9629d9f8c66d0ff9833b6fe0bd Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 22 Feb 2019 08:53:39 -0500 Subject: [PATCH] Abort fetching additional logs if any fail --- buildsrht/blueprints/jobs.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/buildsrht/blueprints/jobs.py b/buildsrht/blueprints/jobs.py index 4425f12..4a98fbb 100644 --- a/buildsrht/blueprints/jobs.py +++ b/buildsrht/blueprints/jobs.py @@ -268,6 +268,7 @@ def job_by_id(username, job_id): "log": logify(r.text, "task-" + name if name else "setup", log_url) }) + return True else: raise Exception() except: @@ -277,14 +278,16 @@ def job_by_id(username, job_id): f'Error fetching logs for task "{escape(name)}"' '') }) + return False log_url = "http://{}/logs/{}/log".format(job.runner, job.id) - get_log(log_url, None) - for task in sorted(job.tasks, key=lambda t: t.id): - if task.status == TaskStatus.pending: - continue - log_url = "http://{}/logs/{}/{}/log".format( - job.runner, job.id, task.name) - get_log(log_url, task.name) + if get_log(log_url, None): + for task in sorted(job.tasks, key=lambda t: t.id): + if task.status == TaskStatus.pending: + continue + log_url = "http://{}/logs/{}/{}/log".format( + job.runner, job.id, task.name) + if not get_log(log_url, task.name): + break return render_template("job.html", job=job, status_map=status_map, -- 2.38.5