Skip to content

Commit

Permalink
mics: copr_new_packages add limit option and progressbar
Browse files Browse the repository at this point in the history
  • Loading branch information
nikromen authored and FrostyX committed Nov 20, 2024
1 parent 5eed3c5 commit b3eeb82
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions misc/copr_new_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import argparse
from datetime import date, timedelta
from copr.v3 import Client
from tqdm import tqdm


# @TODO Check for package review RHBZ and print warnings.
Expand All @@ -34,43 +35,43 @@ def pick_project_candidates(client, projects, since):
succeeded build and at least some project information filled.
"""
rawhide_pks_resp = subprocess.run(
["dnf", "repoquery", "rawhide", "--queryformat", "%{name}", "*"],
["dnf", "--quiet", "--repo=fedora", "repoquery", "--queryformat", "%{name}\n", "*"],
stdout=subprocess.PIPE,
)
fedora_rawhide_pkgs = {x for x in rawhide_pks_resp.stdout.decode().split("\n")}
fedora_rawhide_pkgs = {x for x in rawhide_pks_resp.stdout.decode().split()}

picked = []
for project in projects:
for project in tqdm(projects):
if project.unlisted_on_hp:
print("Skipping {}, it is unlisted on Copr homepage".format(project.full_name))
tqdm.write("Skipping {}, it is unlisted on Copr homepage".format(project.full_name))
continue

if not any([project.description, project.instructions,
project.homepage, project.contact]):
print("Skipping {}, it has no information filled in".format(project.full_name))
tqdm.write("Skipping {}, it has no information filled in".format(project.full_name))
continue

builds = client.build_proxy.get_list(project.ownername, project.name)
if not builds:
print("Skipping {}, no builds".format(project.full_name))
tqdm.write("Skipping {}, no builds".format(project.full_name))
continue

builds = [b for b in builds if b.state == "succeeded"]
if not builds:
print("Skipping {}, no succeeded builds".format(project.full_name))
tqdm.write("Skipping {}, no succeeded builds".format(project.full_name))
continue

builds = filter_unique_package_builds(builds)
builds = [
b for b in builds if b.source_package["name"] not in fedora_rawhide_pkgs
]
if not builds:
print("Skipping {}, all packages already in Fedora".format(project.full_name))
tqdm.write("Skipping {}, all packages already in Fedora".format(project.full_name))
continue

started_on = date.fromtimestamp(builds[-1].started_on)
if started_on < since:
print("Reached older project than {}, ending with {}".format(since, project.full_name))
tqdm.write("Reached older project than {}, ending with {}".format(since, project.full_name))
break

picked.append((project, builds))
Expand Down Expand Up @@ -102,6 +103,13 @@ def get_parser():
type=date.fromisoformat,
help="Search for new projects since YYYY-MM-DD",
)
parser.add_argument(
"--limit",
required=False,
default=1000,
type=int,
help="Limit the number of projects to be checked",
)
return parser


Expand All @@ -110,7 +118,7 @@ def main():
args = parser.parse_args()

client = Client.create_from_config_file()
projects = get_new_projects(client)
projects = get_new_projects(client, args.limit)

print("Going to filter interesting projects since {}".format(args.since))
print("This may take a while, ...")
Expand Down

0 comments on commit b3eeb82

Please sign in to comment.