Skip to content

Commit 286ec33

Browse files
committed
add a koji mangler
1 parent ae1ee87 commit 286ec33

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

mangle/koji/paraimport.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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

Comments
 (0)