-
Notifications
You must be signed in to change notification settings - Fork 1
/
obs-download-rpms.py
executable file
·40 lines (32 loc) · 1.33 KB
/
obs-download-rpms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
import argparse
import concurrent.futures
import os
import shutil
import subprocess
HELP = 'Download all RPM files for a project'
parser = argparse.ArgumentParser(description=HELP)
parser.add_argument('api', help='API')
parser.add_argument('project', help='OBS project name')
parser.add_argument('arch', help='Architecture')
parser.add_argument('output_folder',
help='Output folder where to the RPM files')
parser.add_argument('--jobs', '-j', type=int, default=16,
help='Output folder where to the RPM files')
args = parser.parse_args()
shutil.rmtree(args.output_folder, ignore_errors=True)
os.mkdir(args.output_folder)
packages = subprocess.check_output(f'osc ls -e {args.project}', shell=True,
encoding='utf8').splitlines()
packages = sorted(packages)
def get_package(package):
print(package[0], end='', flush=True)
os.chdir(args.output_folder)
cmd = f'osc getbinaries --debuginfo {args.project} {package} standard {args.arch}'
subprocess.check_output(cmd, shell=True, stderr=subprocess.DEVNULL)
with concurrent.futures.ProcessPoolExecutor(max_workers=args.jobs) as executor:
futures = []
for package in packages:
futures.append(executor.submit(get_package, package))
concurrent.futures.wait(futures)
print()