Skip to content

Commit

Permalink
allow to work with beaker job xml url/file, not just job ID
Browse files Browse the repository at this point in the history
  • Loading branch information
richm committed Jan 15, 2025
1 parent edc5b97 commit 7c74642
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions check_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,17 @@ def parse_avc_log(args, log_url):


def get_beaker_job_info(args, job):
result = subprocess.run(
["bkr", "job-results", job], capture_output=True, text=True, check=True
)
bs = BeautifulSoup(result.stdout, "xml")
if job.endswith(".xml"): # a URL or a local file
if job.startswith("http://") or job.startswith("https://"):
xml_data = requests.get(job).content
else:
xml_data = open(job).read()
bs = BeautifulSoup(xml_data, "xml")
else: # assume it is a job number like J:1213552
result = subprocess.run(
["bkr", "job-results", job], capture_output=True, text=True, check=True
)
bs = BeautifulSoup(result.stdout, "xml")
data = {}
data["job"] = job
data["whiteboard"] = bs.find("whiteboard").text
Expand Down Expand Up @@ -538,15 +545,16 @@ def get_beaker_job_info(args, job):
task_data["name"] = "basic-smoke-test"
log_urls = []
for log in task.find("logs"):
link = log.get("href")
name = log.get("name")
if name == "taskout.log":
task_data["job_data"] = parse_beaker_job_log(
args, task_data["start_time"], link
)
elif name.startswith("SYSTEM-ROLE-"):
task_data["errors"].extend(get_errors_from_ansible_log(args, link))
log_urls.append(link)
if hasattr(log, "get"):
link = log.get("href")
name = log.get("name")
if name == "taskout.log":
task_data["job_data"] = parse_beaker_job_log(
args, task_data["start_time"], link
)
elif name.startswith("SYSTEM-ROLE-"):
task_data["errors"].extend(get_errors_from_ansible_log(args, link))
log_urls.append(link)
task_data["logs"] = log_urls
role = None
task_data["avcs"] = {}
Expand Down Expand Up @@ -749,8 +757,8 @@ def print_ansible_errors(args, errors):
value = "\n".join(item)
else:
value = str(item)
if len(value) > 20000:
value = value[:20000] + ".... truncated"
if len(value) > 5000:
value = value[:5000] + ".... truncated"
value_list.append(value)
values.append(value_list)
sh.values_update(
Expand Down

0 comments on commit 7c74642

Please sign in to comment.