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 committed Nov 11, 2024
1 parent 12c4380 commit 4987a0b
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 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 Down Expand Up @@ -40,37 +41,37 @@ def pick_project_candidates(client, projects, since):
fedora_rawhide_pkgs = {x for x in rawhide_pks_resp.stdout.decode().split("\n")}

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 4987a0b

Please sign in to comment.