|
| 1 | +#!/usr/bin/python3 |
| 2 | + |
| 3 | +import subprocess |
| 4 | +from concurrent.futures import ThreadPoolExecutor |
| 5 | +import os |
| 6 | +import json |
| 7 | +from pathlib import Path |
| 8 | + |
| 9 | +TAG_NAME = 'dist-rocky10' |
| 10 | +FILES_DIR = '/tmp/splits' |
| 11 | +CHUNK_SIZE = 21 |
| 12 | + |
| 13 | +def run_sub(item): |
| 14 | + try: |
| 15 | + with open(item, 'r') as f: |
| 16 | + lines = [line.strip() for line in f if line.strip()] |
| 17 | + results = [] |
| 18 | + for line in lines: |
| 19 | + result = subprocess.run(['koji', 'tag-build', TAG_NAME, str(line)], |
| 20 | + stdout=subprocess.PIPE, |
| 21 | + stderr=subprocess.PIPE) |
| 22 | + results.append({ |
| 23 | + 'package': line, |
| 24 | + 'returncode': result.returncode, |
| 25 | + 'stdout': result.stdout.decode('utf-8').strip(), |
| 26 | + 'stderr': result.stderr.decode('utf-8').strip() |
| 27 | + }) |
| 28 | + return { |
| 29 | + 'file': str(item), |
| 30 | + 'results': results |
| 31 | + } |
| 32 | + except Exception as e: |
| 33 | + return { |
| 34 | + 'file': str(item), |
| 35 | + 'error': str(e) |
| 36 | + } |
| 37 | + |
| 38 | +all_files = sorted(Path(FILES_DIR).glob('*')) |
| 39 | + |
| 40 | +for i in range(0, len(all_files), CHUNK_SIZE): |
| 41 | + chunk = all_files[i:i + CHUNK_SIZE] |
| 42 | + with ThreadPoolExecutor(max_workers=CHUNK_SIZE) as executor: |
| 43 | + results = list(executor.map(run_sub, chunk)) |
| 44 | + for file_result in results: |
| 45 | + print("Finished:", file_result['file']) |
| 46 | + if 'error' in file_result: |
| 47 | + print("Error:", file_result['error']) |
| 48 | + else: |
| 49 | + for r in file_result['results']: |
| 50 | + print(f"{r['package']}: {r['returncode']}") |
0 commit comments