Project

General

Profile

action #132134 » jobs.py

dheidler, 2023-10-02 09:50

 
#!/usr/bin/python3

import json
import subprocess
import sys

jobs = json.loads(subprocess.check_output(['openqa-cli', 'api', '--o3', 'jobs', 'build=dheidler-poo132134-1']))['jobs']

worker_hosts = {}

def gwh(worker_id):
global worker_hosts
if worker_id not in worker_hosts:
worker = json.loads(subprocess.check_output(['openqa-cli', 'api', '--o3', f"workers/{worker_id}"]))['worker']
worker_hosts[worker_id] = worker['host']
return worker_hosts[worker_id]

job_worker = {}

for job in jobs:
if 'assigned_worker_id' in job:
job_worker[job['id']] = job['assigned_worker_id']

print(f"<table>")
for job in jobs:
if not 'controller' in job['name']:
continue
try:
#parallel = job['parents']['Parallel'][0]
parallel = job['children']['Parallel'][0]
except IndexError:
continue
if not 'assigned_worker_id' in job:
continue
if not job_worker.get(parallel):
continue
if gwh(job_worker[job['id']]) != gwh(job_worker[parallel]) and job['result'] == 'passed':
print(f"<tr><td>{job['test']}</td>")
print(f"<td><a href='https://openqa.suse.de/t{job['id']}'>{gwh(job_worker[job['id']])}</a></td>")
print(f"<td><a href='https://openqa.suse.de/t{parallel}'>{gwh(job_worker[parallel])}</a></td>")
print(f"</tr>")
sys.stdout.flush()
print(f"</table>")
(2-2/2)